Create window

This commit is contained in:
2025-12-02 17:11:38 +05:00
parent 16448ef9b8
commit bbb77e1291
4 changed files with 34 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
# filemanager
FileManager on GTK4

14
builder.ui Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GtkWindow" id="window">
<property name="title">File Manager</property>
<property name="default-width">800</property>
<property name="default-height">300</property>
<property name="child">
<object class="GtkLabel" id="label">
<property name="label">Hi</property>
</object>
</property>
</object>
</interface>

1
compile Executable file
View File

@@ -0,0 +1 @@
gcc $(pkg-config --cflags gtk4) -o filemanager.out main.c $(pkg-config --libs gtk4)

18
main.c Normal file
View File

@@ -0,0 +1,18 @@
#include <gtk/gtk.h>
static void app_activate (GtkApplication *app, gpointer *user_data){
GtkBuilder *builder = gtk_builder_new_from_file("builder.ui");
GObject* window = gtk_builder_get_object(builder, "window");
gtk_window_set_application(GTK_WINDOW(window),app);
g_object_unref(builder);
gtk_window_present(GTK_WINDOW(window));
g_print("Started\n");
}
int main (int argc, char **argv){
GtkApplication *app = gtk_application_new ("file.manager", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK(app_activate),NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref(app);
return status;
}