Update gtk28
This commit is contained in:
parent
81037436a0
commit
ecf6a6c6c6
|
@ -0,0 +1 @@
|
||||||
|
default config
|
|
@ -5,23 +5,25 @@
|
||||||
1608375016 /root/cpp50/gtkclass.h
|
1608375016 /root/cpp50/gtkclass.h
|
||||||
<gtk/gtk.h>
|
<gtk/gtk.h>
|
||||||
|
|
||||||
1608632226 source:/root/cpp50/gtkwin.cpp
|
1608645959 source:/root/cpp50/gtkwin.cpp
|
||||||
"gtkwin.h"
|
"gtkwin.h"
|
||||||
"test.h"
|
"test.h"
|
||||||
"winpe.xpm"
|
"winpe.xpm"
|
||||||
"360.xpm"
|
"360.xpm"
|
||||||
|
|
||||||
1608631524 /root/cpp50/gtkwin.h
|
1608645795 /root/cpp50/gtkwin.h
|
||||||
<gtk/gtk.h>
|
<gtk/gtk.h>
|
||||||
|
|
||||||
1608434422 source:/root/cpp50/main.cpp
|
1608434422 source:/root/cpp50/main.cpp
|
||||||
"gtkwin.h"
|
"gtkwin.h"
|
||||||
|
|
||||||
1608611669 source:/root/cpp50/test.cpp
|
1608632300 source:/root/cpp50/test.cpp
|
||||||
"test.h"
|
"test.h"
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
|
"360.xpm"
|
||||||
|
"gtkwin.h"
|
||||||
|
|
||||||
1608631234 /root/cpp50/test.h
|
1608728677 /root/cpp50/test.h
|
||||||
<gtk/gtk.h>
|
<gtk/gtk.h>
|
||||||
|
|
||||||
1608125195 /root/cpp50/360.xpm
|
1608125195 /root/cpp50/360.xpm
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "winpe.xpm"
|
#include "winpe.xpm"
|
||||||
#include "360.xpm"
|
#include "360.xpm"
|
||||||
|
|
||||||
|
//Get a GtkImage from xpm.data
|
||||||
void Icon::get_image(const gchar **str,int width,int height){
|
void Icon::get_image(const gchar **str,int width,int height){
|
||||||
pixbuf=gdk_pixbuf_new_from_xpm_data(str);
|
pixbuf=gdk_pixbuf_new_from_xpm_data(str);
|
||||||
sized=gdk_pixbuf_scale_simple(pixbuf,width,height,GDK_INTERP_BILINEAR);
|
sized=gdk_pixbuf_scale_simple(pixbuf,width,height,GDK_INTERP_BILINEAR);
|
||||||
|
@ -36,6 +37,7 @@ void Winlayout::init(){
|
||||||
put(button1.button,150,100);
|
put(button1.button,150,100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Initalize GtkHeader
|
||||||
void WinHeader::init(GtkWidget *window){
|
void WinHeader::init(GtkWidget *window){
|
||||||
MenuBar menubar;
|
MenuBar menubar;
|
||||||
menubar.menu_init(window);
|
menubar.menu_init(window);
|
||||||
|
@ -44,14 +46,17 @@ void WinHeader::init(GtkWidget *window){
|
||||||
pack_start(menubar.menubar);
|
pack_start(menubar.menubar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//pack widgets on GtkHeader
|
||||||
void WinHeader::pack_start(GtkWidget *child){
|
void WinHeader::pack_start(GtkWidget *child){
|
||||||
gtk_header_bar_pack_start(_header,child);
|
gtk_header_bar_pack_start(_header,child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Append item to GtkMenuBar
|
||||||
void MenuBar::menubar_append(Menuitem child){
|
void MenuBar::menubar_append(Menuitem child){
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menubar),child.menuitem);
|
gtk_menu_shell_append(GTK_MENU_SHELL(menubar),child.menuitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Initalize the menu
|
||||||
void MenuBar::menu_init(GtkWidget *window){
|
void MenuBar::menu_init(GtkWidget *window){
|
||||||
Menuitem menuitem2;
|
Menuitem menuitem2;
|
||||||
Menu menu;
|
Menu menu;
|
||||||
|
@ -74,6 +79,7 @@ void MenuBar::menu_init(GtkWidget *window){
|
||||||
menu.menu_append(menuitem2);
|
menu.menu_append(menuitem2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//append item to GtkMenu
|
||||||
void Menu::menu_append(Menuitem child){
|
void Menu::menu_append(Menuitem child){
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu),child.menuitem);
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu),child.menuitem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
typedef void(*pfun)(GtkWidget *,gpointer);//define a pointer to function
|
typedef void(*pfun)(GtkWidget *,gpointer);//define a pointer to function
|
||||||
|
|
||||||
|
//Convert xpm data to a GtkImage
|
||||||
class Icon{
|
class Icon{
|
||||||
GdkPixbuf *sized;
|
GdkPixbuf *sized;
|
||||||
public:
|
public:
|
||||||
|
@ -25,6 +27,7 @@ class Winlayout{
|
||||||
void init();
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//GtkHeaderbar class
|
||||||
class WinHeader{
|
class WinHeader{
|
||||||
public:
|
public:
|
||||||
GtkWidget *header=gtk_header_bar_new();
|
GtkWidget *header=gtk_header_bar_new();
|
||||||
|
@ -33,12 +36,14 @@ class WinHeader{
|
||||||
void pack_start(GtkWidget *child);
|
void pack_start(GtkWidget *child);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//GtkMenuitem class
|
||||||
class Menuitem{
|
class Menuitem{
|
||||||
public:
|
public:
|
||||||
GtkWidget *menuitem;
|
GtkWidget *menuitem;
|
||||||
void menuitem_init(const gchar *str,pfun func,gpointer data);
|
void menuitem_init(const gchar *str,pfun func,gpointer data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//GtkMenuBar class
|
||||||
class MenuBar{
|
class MenuBar{
|
||||||
public:
|
public:
|
||||||
GtkWidget *menubar=gtk_menu_bar_new();
|
GtkWidget *menubar=gtk_menu_bar_new();
|
||||||
|
@ -46,6 +51,7 @@ class MenuBar{
|
||||||
void menu_init(GtkWidget *window);
|
void menu_init(GtkWidget *window);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//GtkMenu class
|
||||||
class Menu{
|
class Menu{
|
||||||
public:
|
public:
|
||||||
GtkWidget *menu;
|
GtkWidget *menu;
|
||||||
|
@ -64,6 +70,7 @@ class GtkWin{
|
||||||
void show_all();
|
void show_all();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//GtkHBox class (Not the deprecated GtkHbox)
|
||||||
class HBox{
|
class HBox{
|
||||||
public:
|
public:
|
||||||
GtkWidget *hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
GtkWidget *hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
||||||
|
|
|
@ -21,6 +21,10 @@ void about_activate(GtkWidget *widget,gpointer data){
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_activate(GtkWidget *widget,gpointer data){
|
void config_activate(GtkWidget *widget,gpointer data){
|
||||||
|
InputBox("config");
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputBox(const char *filename){
|
||||||
const gchar *str;
|
const gchar *str;
|
||||||
int response;
|
int response;
|
||||||
GtkWidget *dialog=gtk_dialog_new();
|
GtkWidget *dialog=gtk_dialog_new();
|
||||||
|
@ -35,6 +39,7 @@ void config_activate(GtkWidget *widget,gpointer data){
|
||||||
GtkContainer *_content_area=GTK_CONTAINER(content_area);
|
GtkContainer *_content_area=GTK_CONTAINER(content_area);
|
||||||
GtkWidget *label=gtk_label_new("Input config");
|
GtkWidget *label=gtk_label_new("Input config");
|
||||||
GtkWidget *entry=gtk_entry_new();
|
GtkWidget *entry=gtk_entry_new();
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(entry),"default config");
|
||||||
|
|
||||||
gtk_container_add(_content_area,label);
|
gtk_container_add(_content_area,label);
|
||||||
gtk_container_add(_content_area,entry);
|
gtk_container_add(_content_area,entry);
|
||||||
|
@ -42,7 +47,7 @@ void config_activate(GtkWidget *widget,gpointer data){
|
||||||
response=gtk_dialog_run(dialog1);
|
response=gtk_dialog_run(dialog1);
|
||||||
if(response==GTK_RESPONSE_OK){
|
if(response==GTK_RESPONSE_OK){
|
||||||
str=gtk_entry_get_text(GTK_ENTRY(entry));
|
str=gtk_entry_get_text(GTK_ENTRY(entry));
|
||||||
freopen("config","w",stdout);
|
freopen(filename,"w",stdout);
|
||||||
g_print(str);
|
g_print(str);
|
||||||
fclose(stdout);
|
fclose(stdout);
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
|
|
|
@ -6,6 +6,10 @@ void quit(GtkWidget *widget,gpointer data);
|
||||||
|
|
||||||
void config_activate(GtkWidget *widget,gpointer data);
|
void config_activate(GtkWidget *widget,gpointer data);
|
||||||
|
|
||||||
void about_activate(GtkWidget *widget,gpointer data);
|
void InputBox(const char *filename);
|
||||||
|
|
||||||
void MsgBox(const gchar *msg);
|
void MsgBox(const gchar *msg);
|
||||||
|
|
||||||
|
void config_activate(GtkWidget *widget,gpointer data);
|
||||||
|
|
||||||
|
void about_activate(GtkWidget *widget,gpointer data);
|
||||||
|
|
Loading…
Reference in New Issue