Update gtk65
This commit is contained in:
parent
c8d768ccba
commit
29ff1de649
|
@ -4,11 +4,14 @@
|
|||
#define WIN_WIDTH 640
|
||||
#define WIN_HEIGHT 360
|
||||
|
||||
static GtkWidget *background;
|
||||
//static GtkWidget *background;
|
||||
|
||||
static void default_background(int width,int height){
|
||||
static void default_background(int width,int height,gpointer app){
|
||||
//Get background widget
|
||||
GtkWindow *win=gtk_application_get_active_window((GtkApplication*)app);
|
||||
GtkWidget *overlay=gtk_bin_get_child((GtkBin*)win);
|
||||
GtkWidget *background=gtk_bin_get_child((GtkBin*)overlay);
|
||||
//Change background to default
|
||||
//GtkWidget *background;
|
||||
GdkPixbuf *pixbuf=gdk_pixbuf_new_from_xpm_data(img7);
|
||||
GdkPixbuf *sized=gdk_pixbuf_scale_simple(pixbuf,width,height,GDK_INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(background),sized);
|
||||
|
@ -17,7 +20,11 @@ static void default_background(int width,int height){
|
|||
g_object_unref(sized);
|
||||
}
|
||||
|
||||
void set_background(GFile *file1,int width,int height){
|
||||
void set_background(GFile *file1,int width,int height,gpointer app){
|
||||
//Get background widget
|
||||
GtkWindow *win=gtk_application_get_active_window((GtkApplication*)app);
|
||||
GtkWidget *overlay=gtk_bin_get_child((GtkBin*)win);
|
||||
GtkWidget *background=gtk_bin_get_child((GtkBin*)overlay);
|
||||
//Set a background by a file
|
||||
char *filename;
|
||||
filename=g_file_get_path(file1);
|
||||
|
@ -35,7 +42,7 @@ void set_background(GFile *file1,int width,int height){
|
|||
static void fileopen(GtkWidget *widget,int response,gpointer app){
|
||||
if(response==GTK_RESPONSE_OK){
|
||||
GFile *file=gtk_file_chooser_get_file(GTK_FILE_CHOOSER(widget));
|
||||
set_background(file,WIN_WIDTH,WIN_HEIGHT);
|
||||
set_background(file,WIN_WIDTH,WIN_HEIGHT,app);
|
||||
}
|
||||
gtk_widget_destroy(widget);
|
||||
//gtk_window_destroy(GTK_WINDOW(widget));
|
||||
|
@ -45,7 +52,7 @@ static void default_activated(GSimpleAction *action,
|
|||
GVariant *parmeter,
|
||||
gpointer app)
|
||||
{
|
||||
default_background(WIN_WIDTH,WIN_HEIGHT);
|
||||
default_background(WIN_WIDTH,WIN_HEIGHT,app);
|
||||
}
|
||||
|
||||
static void dialog_activated(GSimpleAction *action,
|
||||
|
@ -125,7 +132,7 @@ static void button_press(GtkGesture *gesture,guint n_press,
|
|||
}
|
||||
|
||||
static void gtkmain(GtkApplication *app,gpointer user_data){
|
||||
GtkWidget *window,*overlay,*popover,*draw_area;
|
||||
GtkWidget *window,*overlay,*popover,*draw_area,*background;
|
||||
//Initalize main window
|
||||
window=gtk_application_window_new(app);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window),WIN_WIDTH,WIN_HEIGHT);
|
||||
|
@ -144,7 +151,6 @@ static void gtkmain(GtkApplication *app,gpointer user_data){
|
|||
//Background
|
||||
//background=gtk_picture_new();
|
||||
background=gtk_image_new();
|
||||
default_background(WIN_WIDTH,WIN_HEIGHT);
|
||||
gtk_container_add((GtkContainer*)overlay,background);
|
||||
//gtk_overlay_set_child(GTK_OVERLAY(overlay),background);
|
||||
draw_area=gtk_drawing_area_new();
|
||||
|
@ -172,6 +178,7 @@ static void gtkmain(GtkApplication *app,gpointer user_data){
|
|||
|
||||
//gtk_window_set_child(GTK_WINDOW(window),overlay);
|
||||
gtk_container_add((GtkContainer*)window,overlay);
|
||||
default_background(WIN_WIDTH,WIN_HEIGHT,app);
|
||||
gtk_widget_show_all(window);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue