mirror of https://github.com/daleclack/My_GtkUi
Fix window size for gnome
This commit is contained in:
parent
1c97f54825
commit
cc038c6d8c
|
@ -1,10 +1,7 @@
|
|||
#ifndef __FILE_WINDOW_H_
|
||||
#define __FILE_WINDOW_H_
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE(FileWindow,file_window,FILE,WINDOW,GtkWindow)
|
||||
|
||||
FileWindow * file_window_new(GtkWindow * parent);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -170,6 +170,11 @@ static void gesture_pressed(GtkGestureClick *self,int n_press,double x,double y,
|
|||
gtk_popover_popup(GTK_POPOVER(win->popover));
|
||||
}
|
||||
|
||||
GtkWidget * main_win_get_background(MainWin * win){
|
||||
//Get Background widget, for window size config.
|
||||
return win->background;
|
||||
}
|
||||
|
||||
static GActionEntry entries[] = {
|
||||
{"back",background_dialog,NULL,NULL,NULL},
|
||||
{"default1",default_background1,NULL,NULL,NULL},
|
||||
|
@ -190,7 +195,6 @@ static void main_win_init(MainWin * win){
|
|||
|
||||
//Initailze Window
|
||||
gtk_window_set_icon_name(GTK_WINDOW(win),"My_GtkUI");
|
||||
gtk_window_set_default_size(GTK_WINDOW(win),win->width,win->height);
|
||||
gtk_window_set_title(GTK_WINDOW(win),"My GtkUI (Gtk4 Version)");
|
||||
|
||||
//Add Actions
|
||||
|
@ -199,6 +203,7 @@ static void main_win_init(MainWin * win){
|
|||
//Add Overlay and background widget
|
||||
win->overlay = gtk_overlay_new();
|
||||
win->background = gtk_picture_new();
|
||||
gtk_widget_set_size_request(win->background,win->width,win->height);
|
||||
gtk_overlay_set_child(GTK_OVERLAY(win->overlay),win->background);
|
||||
default_background1(NULL,NULL,win);
|
||||
|
||||
|
|
|
@ -6,4 +6,6 @@ G_DECLARE_FINAL_TYPE(MainWin,main_win,MAIN,WIN,GtkApplicationWindow)
|
|||
|
||||
MainWin * main_win_new(GtkApplication *app);
|
||||
|
||||
GtkWidget * main_win_get_background(MainWin * win);
|
||||
|
||||
void btnabout_clicked(GtkWidget * widget,gpointer data);
|
||||
|
|
|
@ -7,9 +7,10 @@ typedef struct {
|
|||
double y;
|
||||
}MousePos;
|
||||
|
||||
static cairo_surface_t *surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32,640,360);
|
||||
|
||||
//static double start_x,start_y;
|
||||
struct _DrawingApp{
|
||||
cairo_surface_t * cairo_surface;
|
||||
MousePos pos;
|
||||
};
|
||||
|
||||
static void clear_surface (void)
|
||||
{
|
||||
|
@ -27,7 +28,8 @@ static void clear_surface (void)
|
|||
static void resize_cb(GtkWidget *widget,int width,int height,gpointer data){
|
||||
cairo_surface_destroy (surface);
|
||||
cairo_surface_create_similar(surface,CAIRO_CONTENT_COLOR,width,height);
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
|
||||
static gboolean draw_cb(GtkWidget *widget,cairo_t *cr,gpointer data){
|
||||
cairo_set_source_surface(cr,surface,0,0);
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#ifndef __DRAWING_H_
|
||||
#define __DRAWING_H_
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void drawing_main(GtkWidget *widget,GtkWindow *parent);
|
||||
|
||||
#endif
|
||||
//void drawing_main(GtkWidget *widget,GtkWindow *parent);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <cstdio>
|
||||
#include "winconf.h"
|
||||
#include "MainWin.h"
|
||||
|
||||
struct _ConfDlg{
|
||||
GtkDialog parent_instance;
|
||||
|
@ -15,7 +16,7 @@ static void conf_dlg_response(GtkDialog * dialog,int response){
|
|||
width=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(CONF_DLG(dialog)->width_spin));
|
||||
height=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(CONF_DLG(dialog)->height_spin));
|
||||
freopen("winsize.conf","w",stdout);
|
||||
g_print("width=%d\nheight=%d",width,height);
|
||||
g_print("width=%d\nheight=%d\n",width,height);
|
||||
fclose(stdout);
|
||||
}
|
||||
gtk_window_destroy(GTK_WINDOW(dialog));
|
||||
|
@ -33,8 +34,9 @@ static void get_winsize(GtkWidget *widget,ConfDlg * dialog){
|
|||
//Get main window
|
||||
window = gtk_window_get_transient_for(GTK_WINDOW(dialog));
|
||||
//Get Window Size
|
||||
width = gtk_widget_get_size(GTK_WIDGET(window),GTK_ORIENTATION_HORIZONTAL);
|
||||
height = gtk_widget_get_size(GTK_WIDGET(window),GTK_ORIENTATION_VERTICAL);
|
||||
GtkWidget * back = main_win_get_background(MAIN_WIN(window));
|
||||
width = gtk_widget_get_size(back,GTK_ORIENTATION_HORIZONTAL);
|
||||
height = gtk_widget_get_size(back,GTK_ORIENTATION_VERTICAL);
|
||||
//Set Value of spin buttons
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->width_spin),width);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->height_spin),height);
|
||||
|
@ -80,6 +82,12 @@ static void conf_dlg_init(ConfDlg * self){
|
|||
btn_default = gtk_button_new_with_label("Reset to Default Size");
|
||||
btn_getsize = gtk_button_new_with_label("Get Current Size");
|
||||
|
||||
//Get Current Config
|
||||
int width,height;
|
||||
get_config(&width,&height);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(self->width_spin),width);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(self->height_spin),height);
|
||||
|
||||
//Width
|
||||
gtk_box_append(GTK_BOX(box_width),label_width);
|
||||
gtk_box_append(GTK_BOX(box_width),self->width_spin);
|
||||
|
|
Loading…
Reference in New Issue