2021-02-13 11:58:43 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "background.h"
|
2021-02-14 10:45:51 +08:00
|
|
|
#include "winconf.h"
|
2021-02-13 11:58:43 +08:00
|
|
|
|
|
|
|
static void gtkmain(GtkApplication *app,gpointer user_data){
|
|
|
|
//Get main window
|
2021-02-14 10:45:51 +08:00
|
|
|
int width,height;
|
|
|
|
get_config(&width,&height);
|
2021-02-13 11:58:43 +08:00
|
|
|
GtkBuilder *builder=gtk_builder_new_from_file("res/window.ui");
|
|
|
|
GObject *window=gtk_builder_get_object(builder,"window");
|
2021-02-14 10:45:51 +08:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(window),width,height);
|
2021-02-13 11:58:43 +08:00
|
|
|
//Get button for change background
|
|
|
|
GObject *btn_back=gtk_builder_get_object(builder,"btnback");
|
|
|
|
g_signal_connect(btn_back,"clicked",G_CALLBACK(fileopen),builder);
|
2021-02-14 10:45:51 +08:00
|
|
|
//Config button
|
|
|
|
GObject *btn_conf=gtk_builder_get_object(builder,"btnset");
|
|
|
|
g_signal_connect(btn_conf,"clicked",G_CALLBACK(conf_dialog),builder);
|
2021-02-13 11:58:43 +08:00
|
|
|
//default background
|
|
|
|
default_background(builder);
|
|
|
|
//Add window to the application and show
|
|
|
|
gtk_application_add_window(app,GTK_WINDOW(window));
|
|
|
|
gtk_widget_show_all(GTK_WIDGET(window));
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc,char *argv[]){
|
|
|
|
GtkApplication *app;
|
|
|
|
int status;
|
|
|
|
app=gtk_application_new("com.github.daleclack.gtk42",G_APPLICATION_FLAGS_NONE);
|
|
|
|
g_signal_connect(app,"activate",G_CALLBACK(gtkmain),NULL);
|
|
|
|
status=g_application_run(G_APPLICATION(app),argc,argv);
|
|
|
|
return status;
|
|
|
|
}
|