gplugin/gplugin

Make GPluginGtkPluginInfo display plugin dependencies.
develop
2020-07-05, Alejandro GarcĂ­a <>
6bc46e33a0b2
Parents 819c2165e226
Children 0c835c7577ab
Make GPluginGtkPluginInfo display plugin dependencies.

Fixes [GPLUGIN-124 GPluginGtkPluginInfo doesn't show dependencies](https://issues.imfreedom.org/issue/GPLUGIN-124).

Reviewed at https://reviews.imfreedom.org/r/22/
--- a/gplugin-gtk/data/plugin-info.ui Wed Jul 01 02:17:10 2020 -0500
+++ b/gplugin-gtk/data/plugin-info.ui Sun Jul 05 04:21:04 2020 -0500
@@ -240,11 +240,13 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="dependencies">
+ <object class="GtkBox" id="dependencies_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="expand">False</property>
--- a/gplugin-gtk/gplugin-gtk-plugin-info.c Wed Jul 01 02:17:10 2020 -0500
+++ b/gplugin-gtk/gplugin-gtk-plugin-info.c Sun Jul 05 04:21:04 2020 -0500
@@ -18,6 +18,8 @@
#include <gplugin.h>
#include <gplugin-gtk/gplugin-gtk-plugin-info.h>
+#include <glib/gi18n-lib.h>
+
/**
* SECTION:gplugin-gtk-plugin-info
* @title: Plugin Info Gtk Widgets
@@ -53,7 +55,7 @@
GtkWidget *website;
GtkWidget *summary;
GtkWidget *description;
- GtkWidget *dependencies;
+ GtkWidget *dependencies_box;
GtkWidget *error;
GtkWidget *expander;
GtkWidget *id;
@@ -106,6 +108,7 @@
gchar *summary = NULL, *description = NULL, *id = NULL, *abi_version = NULL;
gchar *loader = NULL;
gchar **authors = NULL;
+ gchar **dependencies = NULL;
guint32 abi_version_uint;
gboolean loq = FALSE, internal = FALSE;
const gchar *filename = NULL;
@@ -116,6 +119,12 @@
gtk_widget_destroy(GTK_WIDGET(iter->data));
g_list_free(children);
+ /* remove all the children from the dependencies box */
+ children = gtk_container_get_children(GTK_CONTAINER(info->dependencies_box));
+ for(iter = children; iter; iter = iter->next)
+ gtk_widget_destroy(GTK_WIDGET(iter->data));
+ g_list_free(children);
+
/* now get the info if we can */
if(GPLUGIN_IS_PLUGIN(info->plugin)) {
GPluginPluginInfo *plugin_info = gplugin_plugin_get_info(info->plugin);
@@ -137,6 +146,7 @@
"authors", &authors,
"summary", &summary,
"description", &description,
+ "dependencies", &dependencies,
"id", &id,
"internal", &internal,
"load-on-query", &loq,
@@ -215,6 +225,34 @@
}
}
g_strfreev(authors);
+
+ /* set the dependencies */
+ if(dependencies) {
+ gint i = 0;
+
+ for(i = 0; dependencies[i]; i++) {
+ widget = gtk_label_new(dependencies[i]);
+ gtk_widget_set_halign(widget, GTK_ALIGN_START);
+ gtk_widget_set_valign(widget, GTK_ALIGN_START);
+ gtk_box_pack_start(
+ GTK_BOX(info->dependencies_box),
+ widget,
+ TRUE,
+ TRUE,
+ 0);
+ gtk_widget_show(widget);
+ }
+ } else {
+ widget = gtk_label_new(_("(none)"));
+ gtk_box_pack_start(
+ GTK_BOX(info->dependencies_box),
+ widget,
+ TRUE,
+ TRUE,
+ 0);
+ gtk_widget_show(widget);
+ }
+ g_strfreev(dependencies);
}
/******************************************************************************
@@ -339,7 +377,7 @@
gtk_widget_class_bind_template_child(
widget_class,
GPluginGtkPluginInfo,
- dependencies);
+ dependencies_box);
gtk_widget_class_bind_template_child(
widget_class,
GPluginGtkPluginInfo,