# HG changeset patch
# Node ID 41c73f7a6b37
# Parent  5dfb747dafa8
diff --git a/gplugin-gtk4/data/plugin-row.ui b/gplugin-gtk4/data/plugin-row.ui
--- a/gplugin-gtk4/data/plugin-row.ui
+++ b/gplugin-gtk4/data/plugin-row.ui
@@ -19,14 +19,14 @@
               <object class="GtkSwitch" id="enable">
                 <property name="valign">center</property>
                 <binding name="sensitive">
-                  <closure type="gboolean" function="gplugin_gtk_plugin_row_lookup_sensitive_cb">
+                  <closure type="gboolean" function="gplugin_gtk_lookup_plugin_state_sensitivity">
                     <lookup name="state" type="GPluginPlugin">
                       <lookup name="plugin">GPluginGtkPluginRow</lookup>
                     </lookup>
                   </closure>
                 </binding>
                 <binding name="state">
-                  <closure type="gboolean" function="gplugin_gtk_plugin_row_lookup_state_cb">
+                  <closure type="gboolean" function="gplugin_gtk_lookup_plugin_state">
                     <lookup name="state" type="GPluginPlugin">
                       <lookup name="plugin">GPluginGtkPluginRow</lookup>
                     </lookup>
@@ -46,7 +46,7 @@
                     <property name="css-classes">heading</property>
                     <property name="hexpand">1</property>
                     <binding name="label">
-                      <closure type="gchararray" function="gplugin_gtk_plugin_row_lookup_name_cb">
+                      <closure type="gchararray" function="gplugin_gtk_lookup_plugin_name">
                         <lookup name="info" type="GPluginPlugin">
                           <lookup name="plugin">GPluginGtkPluginRow</lookup>
                         </lookup>
diff --git a/gplugin-gtk4/gplugin-gtk-plugin-closures.h b/gplugin-gtk4/gplugin-gtk-plugin-closures.h
new file mode 100644
--- /dev/null
+++ b/gplugin-gtk4/gplugin-gtk-plugin-closures.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(GPLUGIN_GTK_GLOBAL_HEADER_INSIDE) && \
+	!defined(GPLUGIN_GTK_COMPILATION)
+#error "only <gplugin-gtk.h> may be included directly"
+#endif
+
+#ifndef GPLUGIN_GTK_PLUGIN_CLOSURES_H
+#define GPLUGIN_GTK_PLUGIN_CLOSURES_H
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+
+#include <gplugin.h>
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL
+gchar *gplugin_gtk_lookup_plugin_name(
+	GtkClosureExpression *expression,
+	GPluginPluginInfo *info,
+	const gchar *filename,
+	gpointer data);
+
+G_GNUC_INTERNAL
+gboolean gplugin_gtk_lookup_plugin_state_sensitivity(
+	GtkClosureExpression *expression,
+	GPluginPluginState state,
+	gpointer data);
+
+G_GNUC_INTERNAL
+gboolean gplugin_gtk_lookup_plugin_state(
+	GtkClosureExpression *expression,
+	GPluginPluginState state,
+	gpointer data);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_GTK_PLUGIN_CLOSURES_H */
diff --git a/gplugin-gtk4/gplugin-gtk-plugin-closures.c b/gplugin-gtk4/gplugin-gtk-plugin-closures.c
new file mode 100644
--- /dev/null
+++ b/gplugin-gtk4/gplugin-gtk-plugin-closures.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n-lib.h>
+
+#include <gplugin.h>
+
+#include <gplugin-gtk-plugin-closures.h>
+
+/******************************************************************************
+ * Private API
+ *****************************************************************************/
+
+gchar *
+gplugin_gtk_lookup_plugin_name(
+	G_GNUC_UNUSED GtkClosureExpression *expression,
+	GPluginPluginInfo *info,
+	const gchar *filename,
+	G_GNUC_UNUSED gpointer data)
+{
+	const gchar *name = NULL;
+	gchar *basename = NULL;
+	gchar *unnamed = NULL;
+
+	name = gplugin_plugin_info_get_name(info);
+	if(name != NULL) {
+		return g_strdup(name);
+	}
+
+	/* Add a default name if unavailable. */
+	basename = g_path_get_basename(filename);
+	unnamed = g_strdup_printf(_("Unnamed Plugin: %s"), basename);
+	g_free(basename);
+
+	return unnamed;
+}
+
+gboolean
+gplugin_gtk_lookup_plugin_state_sensitivity(
+	G_GNUC_UNUSED GtkClosureExpression *expression,
+	GPluginPluginState state,
+	G_GNUC_UNUSED gpointer data)
+{
+	gboolean result = FALSE;
+
+	switch(state) {
+		case GPLUGIN_PLUGIN_STATE_QUERIED:
+		case GPLUGIN_PLUGIN_STATE_REQUERY:
+		case GPLUGIN_PLUGIN_STATE_LOADED:
+			result = TRUE;
+			break;
+
+		case GPLUGIN_PLUGIN_STATE_UNLOAD_FAILED:
+		case GPLUGIN_PLUGIN_STATE_ERROR:
+		case GPLUGIN_PLUGIN_STATE_LOAD_FAILED:
+		case GPLUGIN_PLUGIN_STATE_UNKNOWN:
+		default:
+			result = FALSE;
+			break;
+	}
+
+	return result;
+}
+
+gboolean
+gplugin_gtk_lookup_plugin_state(
+	G_GNUC_UNUSED GtkClosureExpression *expression,
+	GPluginPluginState state,
+	G_GNUC_UNUSED gpointer data)
+{
+	gboolean result = FALSE;
+
+	switch(state) {
+		case GPLUGIN_PLUGIN_STATE_LOADED:
+		case GPLUGIN_PLUGIN_STATE_UNLOAD_FAILED:
+			result = TRUE;
+			break;
+
+		case GPLUGIN_PLUGIN_STATE_QUERIED:
+		case GPLUGIN_PLUGIN_STATE_REQUERY:
+		case GPLUGIN_PLUGIN_STATE_ERROR:
+		case GPLUGIN_PLUGIN_STATE_LOAD_FAILED:
+		case GPLUGIN_PLUGIN_STATE_UNKNOWN:
+		default:
+			result = FALSE;
+			break;
+	}
+
+	return result;
+}
diff --git a/gplugin-gtk4/gplugin-gtk-plugin-row.c b/gplugin-gtk4/gplugin-gtk-plugin-row.c
--- a/gplugin-gtk4/gplugin-gtk-plugin-row.c
+++ b/gplugin-gtk4/gplugin-gtk-plugin-row.c
@@ -19,6 +19,7 @@
 
 #include <gplugin.h>
 
+#include <gplugin-gtk-plugin-closures.h>
 #include <gplugin-gtk-plugin-row.h>
 
 /**
@@ -223,84 +224,6 @@ gplugin_gtk_plugin_row_enable_state_set_
 	return TRUE;
 }
 
-static gchar *
-gplugin_gtk_plugin_row_lookup_name_cb(
-	G_GNUC_UNUSED GtkClosureExpression *expression,
-	GPluginPluginInfo *info,
-	const gchar *filename,
-	G_GNUC_UNUSED gpointer data)
-{
-	const gchar *name = NULL;
-	gchar *basename = NULL;
-	gchar *unnamed = NULL;
-
-	name = gplugin_plugin_info_get_name(info);
-	if(name != NULL) {
-		return g_strdup(name);
-	}
-
-	/* Add a default name if unavailable. */
-	basename = g_path_get_basename(filename);
-	unnamed = g_strdup_printf(_("Unnamed Plugin: %s"), basename);
-	g_free(basename);
-
-	return unnamed;
-}
-
-static gboolean
-gplugin_gtk_plugin_row_lookup_sensitive_cb(
-		G_GNUC_UNUSED GtkClosureExpression *expression,
-		GPluginPluginState state,
-		G_GNUC_UNUSED gpointer data)
-{
-	gboolean result = FALSE;
-
-	switch(state) {
-		case GPLUGIN_PLUGIN_STATE_QUERIED:
-		case GPLUGIN_PLUGIN_STATE_REQUERY:
-		case GPLUGIN_PLUGIN_STATE_LOADED:
-			result = TRUE;
-			break;
-
-		case GPLUGIN_PLUGIN_STATE_UNLOAD_FAILED:
-		case GPLUGIN_PLUGIN_STATE_ERROR:
-		case GPLUGIN_PLUGIN_STATE_LOAD_FAILED:
-		case GPLUGIN_PLUGIN_STATE_UNKNOWN:
-		default:
-			result = FALSE;
-			break;
-	}
-
-	return result;
-}
-
-static gboolean
-gplugin_gtk_plugin_row_lookup_state_cb(
-		G_GNUC_UNUSED GtkClosureExpression *expression,
-		GPluginPluginState state,
-		G_GNUC_UNUSED gpointer data)
-{
-	gboolean result = FALSE;
-
-	switch(state) {
-		case GPLUGIN_PLUGIN_STATE_LOADED:
-		case GPLUGIN_PLUGIN_STATE_UNLOAD_FAILED:
-			result = TRUE;
-			break;
-
-		case GPLUGIN_PLUGIN_STATE_QUERIED:
-		case GPLUGIN_PLUGIN_STATE_REQUERY:
-		case GPLUGIN_PLUGIN_STATE_ERROR:
-		case GPLUGIN_PLUGIN_STATE_LOAD_FAILED:
-		case GPLUGIN_PLUGIN_STATE_UNKNOWN:
-		default:
-			result = FALSE;
-			break;
-	}
-
-	return result;
-}
-
 /******************************************************************************
  * GObject Implementation
  *****************************************************************************/
@@ -450,13 +373,13 @@ gplugin_gtk_plugin_row_class_init(GPlugi
 		gplugin_gtk_plugin_row_enable_state_set_cb);
 	gtk_widget_class_bind_template_callback(
 		widget_class,
-		gplugin_gtk_plugin_row_lookup_name_cb);
+		gplugin_gtk_lookup_plugin_name);
 	gtk_widget_class_bind_template_callback(
 		widget_class,
-		gplugin_gtk_plugin_row_lookup_sensitive_cb);
+		gplugin_gtk_lookup_plugin_state);
 	gtk_widget_class_bind_template_callback(
 		widget_class,
-		gplugin_gtk_plugin_row_lookup_state_cb);
+		gplugin_gtk_lookup_plugin_state_sensitivity);
 
 	/* Details */
 	gtk_widget_class_bind_template_child(
diff --git a/gplugin-gtk4/meson.build b/gplugin-gtk4/meson.build
--- a/gplugin-gtk4/meson.build
+++ b/gplugin-gtk4/meson.build
@@ -19,9 +19,11 @@ GPLUGIN_GTK4_HEADERS = [
 ]
 
 GPLUGIN_GTK4_PRIVATE_SOURCES = [
+	'gplugin-gtk-plugin-closures.c',
 ]
 
 GPLUGIN_GTK4_PRIVATE_HEADERS = [
+	'gplugin-gtk-plugin-closures.h',
 ]
 
 GPLUGIN_GTK4_PUBLIC_BUILT_SOURCES = [
