[gnome-builder] prefs: add plugins list page



commit d021b279f067ca17db22edbd7d67bdb5a97bfe7e
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 8 20:35:08 2015 -0700

    prefs: add plugins list page
    
    This is read-only currently, but gives the user the ability to see the
    list of installed plugins.

 data/theme/Adwaita-shared.css                 |    8 ++
 data/ui/gb-preferences-page-plugins.ui        |   36 ++++++
 data/ui/gb-preferences-window.ui              |    9 ++
 src/Makefile.am                               |    2 +
 src/preferences/gb-preferences-page-plugins.c |  142 +++++++++++++++++++++++++
 src/preferences/gb-preferences-page-plugins.h |   32 ++++++
 src/preferences/gb-preferences-window.c       |    2 +
 src/resources/gnome-builder.gresource.xml     |    1 +
 8 files changed, 232 insertions(+), 0 deletions(-)
---
diff --git a/data/theme/Adwaita-shared.css b/data/theme/Adwaita-shared.css
index 6af6067..3728988 100644
--- a/data/theme/Adwaita-shared.css
+++ b/data/theme/Adwaita-shared.css
@@ -103,3 +103,11 @@ SymbolTree GtkSearchEntry {
 .shortcuts-list-box GtkLabel {
   padding: 6px;
 }
+
+
+GbPreferencesPagePlugins GtkListBoxRow {
+  border-bottom: 1px solid shade(@borders, 1.2);
+}
+.shortcuts-list-box GtkListBoxRow:last-child {
+  border-bottom: none;
+}
diff --git a/data/ui/gb-preferences-page-plugins.ui b/data/ui/gb-preferences-page-plugins.ui
new file mode 100644
index 0000000..9a17fc0
--- /dev/null
+++ b/data/ui/gb-preferences-page-plugins.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.16 -->
+  <template class="GbPreferencesPagePlugins" parent="GbPreferencesPage">
+    <property name="title" translatable="yes">Plugins</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">true</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="visible">true</property>
+            <child>
+              <object class="GtkBox">
+                <property name="orientation">vertical</property>
+                <property name="visible">true</property>
+                <child>
+                  <object class="GtkFrame">
+                    <property name="visible">true</property>
+                    <property name="border-width">12</property>
+                    <property name="shadow-type">in</property>
+                    <child>
+                      <object class="GtkListBox" id="list_box">
+                        <property name="selection-mode">none</property>
+                        <property name="visible">true</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/data/ui/gb-preferences-window.ui b/data/ui/gb-preferences-window.ui
index ae59c35..29bd05e 100644
--- a/data/ui/gb-preferences-window.ui
+++ b/data/ui/gb-preferences-window.ui
@@ -174,6 +174,15 @@
                 <property name="title" translatable="yes">Version Control</property>
               </packing>
             </child>
+            <child>
+              <object class="GbPreferencesPagePlugins" id="plugins_page">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="name">plugins</property>
+                <property name="title" translatable="yes">Plugins</property>
+              </packing>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/Makefile.am b/src/Makefile.am
index c69ac44..6d2976f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -77,6 +77,8 @@ libgnome_builder_la_SOURCES = \
        preferences/gb-preferences-page-keybindings.h \
        preferences/gb-preferences-page-language.c \
        preferences/gb-preferences-page-language.h \
+       preferences/gb-preferences-page-plugins.c \
+       preferences/gb-preferences-page-plugins.h \
        preferences/gb-preferences-page-theme.c \
        preferences/gb-preferences-page-theme.h \
        preferences/gb-preferences-page.c \
diff --git a/src/preferences/gb-preferences-page-plugins.c b/src/preferences/gb-preferences-page-plugins.c
new file mode 100644
index 0000000..e400f77
--- /dev/null
+++ b/src/preferences/gb-preferences-page-plugins.c
@@ -0,0 +1,142 @@
+/* gb-preferences-page-plugins.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+#include <ide.h>
+#include <libpeas/peas.h>
+
+#include "gb-preferences-page-plugins.h"
+
+struct _GbPreferencesPagePlugins
+{
+  GbPreferencesPage parent_instance;
+
+  GtkListBox *list_box;
+};
+
+G_DEFINE_TYPE (GbPreferencesPagePlugins, gb_preferences_page_plugins, GB_TYPE_PREFERENCES_PAGE)
+
+static void
+gb_preferences_page_plugins_add_plugin (GbPreferencesPagePlugins *self,
+                                        PeasPluginInfo           *plugin_info)
+{
+  const gchar *description;
+  const gchar *name;
+  GtkListBoxRow *row;
+  GtkLabel *label;
+  GtkBox *box;
+
+  g_assert (GB_IS_PREFERENCES_PAGE_PLUGINS (self));
+  g_assert (plugin_info != NULL);
+
+  name = peas_plugin_info_get_name (plugin_info);
+  description = peas_plugin_info_get_description (plugin_info);
+
+  if (ide_str_equal0 (name, "Fallback"))
+    return;
+
+  row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
+                      "visible", TRUE,
+                      NULL);
+  g_object_set_data (G_OBJECT (row), "PEAS_PLUGIN_INFO", plugin_info);
+  gtk_container_add (GTK_CONTAINER (self->list_box), GTK_WIDGET (row));
+
+  box = g_object_new (GTK_TYPE_BOX,
+                      "margin", 6,
+                      "orientation", GTK_ORIENTATION_VERTICAL,
+                      "visible", TRUE,
+                      NULL);
+  gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (box));
+
+  label = g_object_new (GTK_TYPE_LABEL,
+                        "label", name,
+                        "visible", TRUE,
+                        "xalign", 0.0f,
+                        NULL);
+  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (label));
+
+  label = g_object_new (GTK_TYPE_LABEL,
+                        "label", description,
+                        "visible", TRUE,
+                        "xalign", 0.0f,
+                        "wrap", TRUE,
+                        NULL);
+  gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (label)), "dim-label");
+  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (label));
+}
+
+static void
+gb_preferences_page_plugins_reload (GbPreferencesPagePlugins *self)
+{
+  PeasEngine *engine;
+  const GList *plugins;
+  const GList *iter;
+  GList *children;
+
+  g_assert (GB_IS_PREFERENCES_PAGE_PLUGINS (self));
+
+  engine = peas_engine_get_default ();
+
+  children = gtk_container_get_children (GTK_CONTAINER (self->list_box));
+  for (iter = children; iter; iter = iter->next)
+    gtk_container_remove (GTK_CONTAINER (self->list_box), iter->data);
+  g_list_free (children);
+
+  plugins = peas_engine_get_plugin_list (engine);
+  for (iter = plugins; iter; iter = iter->next)
+    gb_preferences_page_plugins_add_plugin (self, iter->data);
+}
+
+static gint
+sort_rows_func (GtkListBoxRow *row1,
+                GtkListBoxRow *row2,
+                gpointer       user_data)
+{
+  PeasPluginInfo *pi1 = g_object_get_data (G_OBJECT (row1), "PEAS_PLUGIN_INFO");
+  PeasPluginInfo *pi2 = g_object_get_data (G_OBJECT (row2), "PEAS_PLUGIN_INFO");
+  const gchar *name1 = peas_plugin_info_get_name (pi1);
+  const gchar *name2 = peas_plugin_info_get_name (pi2);
+
+  return g_utf8_collate (name1, name2);
+}
+
+static void
+gb_preferences_page_plugins_class_init (GbPreferencesPagePluginsClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/ui/gb-preferences-page-plugins.ui");
+
+  gtk_widget_class_bind_template_child (widget_class, GbPreferencesPagePlugins, list_box);
+}
+
+static void
+gb_preferences_page_plugins_init (GbPreferencesPagePlugins *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+
+  g_signal_connect_object (peas_engine_get_default (),
+                           "notify::plugin-list",
+                           G_CALLBACK (gb_preferences_page_plugins_reload),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  gtk_list_box_set_sort_func (self->list_box, sort_rows_func, NULL, NULL);
+
+  gb_preferences_page_plugins_reload (self);
+}
diff --git a/src/preferences/gb-preferences-page-plugins.h b/src/preferences/gb-preferences-page-plugins.h
new file mode 100644
index 0000000..3a999b9
--- /dev/null
+++ b/src/preferences/gb-preferences-page-plugins.h
@@ -0,0 +1,32 @@
+/* gb-preferences-page-plugins.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_PREFERENCES_PAGE_PLUGINS_H
+#define GB_PREFERENCES_PAGE_PLUGINS_H
+
+#include "gb-preferences-page.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_PREFERENCES_PAGE_PLUGINS (gb_preferences_page_plugins_get_type())
+
+G_DECLARE_FINAL_TYPE (GbPreferencesPagePlugins, gb_preferences_page_plugins, GB, PREFERENCES_PAGE_PLUGINS, 
GbPreferencesPage)
+
+G_END_DECLS
+
+#endif /* GB_PREFERENCES_PAGE_PLUGINS_H */
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index 7f06aba..38a87a4 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -26,6 +26,7 @@
 #include "gb-preferences-page-insight.h"
 #include "gb-preferences-page-keybindings.h"
 #include "gb-preferences-page-language.h"
+#include "gb-preferences-page-plugins.h"
 #include "gb-preferences-page-theme.h"
 #include "gb-preferences-page.h"
 #include "gb-preferences-window.h"
@@ -276,6 +277,7 @@ gb_preferences_window_class_init (GbPreferencesWindowClass *klass)
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_INSIGHT);
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_KEYBINDINGS);
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_LANGUAGE);
+  g_type_ensure (GB_TYPE_PREFERENCES_PAGE_PLUGINS);
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_THEME);
 }
 
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 028d89d..ec089d7 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -32,6 +32,7 @@
     <file alias="ui/gb-preferences-page-insight.ui">../../data/ui/gb-preferences-page-insight.ui</file>
     <file 
alias="ui/gb-preferences-page-keybindings.ui">../../data/ui/gb-preferences-page-keybindings.ui</file>
     <file alias="ui/gb-preferences-page-language.ui">../../data/ui/gb-preferences-page-language.ui</file>
+    <file alias="ui/gb-preferences-page-plugins.ui">../../data/ui/gb-preferences-page-plugins.ui</file>
     <file alias="ui/gb-preferences-page-theme.ui">../../data/ui/gb-preferences-page-theme.ui</file>
     <file alias="ui/gb-preferences-switch.ui">../../data/ui/gb-preferences-switch.ui</file>
     <file alias="ui/gb-preferences-window.ui">../../data/ui/gb-preferences-window.ui</file>


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