Create Main Object

This commit is contained in:
daleclack 2023-06-09 17:02:26 +08:00
parent 303d24e515
commit 230bd06029
5 changed files with 28 additions and 12 deletions

View File

@ -23,7 +23,7 @@ pkg_check_modules (GTK REQUIRED gtk4)
include_directories (${GTK_INCLUDE_DIRS})
link_directories (${GTK_LIBRARY_DIRS})
set(SOURCES src/core/main.cpp)
set(SOURCES src/core/main.cpp src/core/MainWin.cpp)
#Compile resources with GCR_CMake

View File

@ -0,0 +1,15 @@
#include "MainWin.h"
struct _MainWin{
GtkApplicationWindow parent_class;
};
G_DEFINE_TYPE(MainWin, main_win, GTK_TYPE_APPLICATION_WINDOW)
static void main_win_init(MainWin *win){}
static void main_win_class_init(MainWinClass *win_class){}
MainWin *main_win_new(GtkApplication *app){
return MAIN_WIN(g_object_new(main_win_get_type(), "application", app, NULL));
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <gtk/gtk.h>
// Declare type for main window
G_DECLARE_FINAL_TYPE(MainWin, main_win, MAIN, WIN, GtkApplicationWindow)
// Create a new main window
MainWin *main_win_new(GtkApplication *app);

View File

@ -1,8 +0,0 @@
#include "MyWin.hh"
int main(int argc,char ** argv){
// Create a application and window, start the application
auto app = Gtk::Application::create("org.gtk.daleclack");
// MyWin window;
return app->make_window_and_run<MyWin>(argc, argv);
}

View File

@ -1,9 +1,9 @@
#include <gtk/gtk.h>
#include "MainWin.h"
static void gtkmain(GtkApplication *app, gpointer data)
{
GtkWidget *window;
window = gtk_application_window_new(app);
MainWin *window;
window = main_win_new(app);
gtk_window_present(GTK_WINDOW(window));
}