Gnome extension for core22

core22 snaps should be able to use the gnome extension. That functionality was just added last week. The new gnome plugin has not yet been added to the documentation.

Example usage from snapcraft source:

name: gtk3-hello
version: "1.0"
summary: test the gnome extension
description: This is a basic gtk snap

grade: devel
base: core22
confinement: strict

apps:
  gtk3-hello:
    command: usr/local/bin/gtk3-hello
    extensions: [gnome]

parts:
  project:
    plugin: cmake
    source: .

# Temporarily use snaps from edge
build-snaps: [gnome-42-2204-sdk/latest/edge, gnome-42-2204/latest/edge]
hello.c
#include <gtk/gtk.h>

// Not called.
void activate(GtkApplication *app, gpointer user_data)
{
	g_print("ACTIVATED");
}

int main (int argc, char **argv)
{
	void *app = gtk_application_new("io.snapcraft.gtk-test", G_APPLICATION_FLAGS_NONE);
	g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);

	// Requires display.
	//int status = g_application_run(G_APPLICATION(app), argc, argv);

	g_print("hello world\n");

	g_object_unref(app);
	return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(gtk-hello C)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
add_executable(gtk3-hello hello.c)
target_include_directories(gtk3-hello PRIVATE ${GTK3_INCLUDE_DIRS})
target_link_libraries(gtk3-hello ${GTK3_LIBRARIES})
install(TARGETS gtk3-hello RUNTIME DESTINATION bin)
1 Like