mirror of https://github.com/daleclack/My_GtkUi
Add About window
This commit is contained in:
parent
4cb0dfaa74
commit
ad377527eb
|
@ -4,6 +4,7 @@
|
|||
<section>
|
||||
<item>
|
||||
<attribute name="label">About My GtkUI Mac version</attribute>
|
||||
<attribute name="action">win.about</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Software Update...</attribute>
|
||||
|
|
|
@ -2,52 +2,98 @@
|
|||
#include "winpe.xpm"
|
||||
|
||||
MyWin::MyWin()
|
||||
:menubox(Gtk::ORIENTATION_HORIZONTAL,0)
|
||||
: menubox(Gtk::ORIENTATION_HORIZONTAL, 0)
|
||||
{
|
||||
//Initalize window
|
||||
set_default_size(1024,576);
|
||||
// Initalize window
|
||||
set_default_size(1024, 576);
|
||||
set_icon_name("My_GtkUI");
|
||||
set_title("My GtkUI macOS Version");
|
||||
|
||||
//Add background
|
||||
// Add background
|
||||
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
|
||||
auto sized = pixbuf->scale_simple(1024,576,Gdk::INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(m_background.gobj(),sized->gobj());
|
||||
auto sized = pixbuf->scale_simple(1024, 576, Gdk::INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(m_background.gobj(), sized->gobj());
|
||||
m_overlay.add(m_background);
|
||||
|
||||
//Add Action for menus
|
||||
add_action("logout",sigc::mem_fun(*this,&MyWin::logout_activated));
|
||||
add_action("quit",sigc::mem_fun(*this,&MyWin::quit_activated));
|
||||
// Add Action for menus
|
||||
add_action("logout", sigc::mem_fun(*this, &MyWin::logout_activated));
|
||||
add_action("quit", sigc::mem_fun(*this, &MyWin::quit_activated));
|
||||
add_action("about",sigc::mem_fun(*this,&MyWin::about_activated));
|
||||
|
||||
//Add Stack
|
||||
// Add Stack
|
||||
m_overlay.add_overlay(*(main_stack.stack));
|
||||
|
||||
//Add context menu
|
||||
// Add context menu
|
||||
auto menubuilder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/mainmenu.xml");
|
||||
auto object = menubuilder->get_object("model");
|
||||
auto gmenu = Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
|
||||
context_menu.bind_model(gmenu);
|
||||
context_menu.set_relative_to(m_overlay);
|
||||
|
||||
//Add Gesture for control
|
||||
// Add Gesture for control
|
||||
gesture = Gtk::GestureMultiPress::create(m_overlay);
|
||||
gesture->set_button(GDK_BUTTON_SECONDARY);
|
||||
gesture->signal_pressed().connect(sigc::mem_fun(*this,&MyWin::press));
|
||||
gesture->signal_pressed().connect(sigc::mem_fun(*this, &MyWin::press));
|
||||
|
||||
add(m_overlay);
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
void MyWin::press(int n_press,double x,double y){
|
||||
//Show Menu
|
||||
context_menu.set_pointing_to(Gdk::Rectangle((int)x,(int)y,1,1));
|
||||
void MyWin::press(int n_press, double x, double y)
|
||||
{
|
||||
// Show Menu
|
||||
context_menu.set_pointing_to(Gdk::Rectangle((int)x, (int)y, 1, 1));
|
||||
context_menu.popup();
|
||||
}
|
||||
|
||||
void MyWin::logout_activated(){
|
||||
void MyWin::logout_activated()
|
||||
{
|
||||
main_stack.logout();
|
||||
}
|
||||
|
||||
void MyWin::quit_activated(){
|
||||
void MyWin::about_activated()
|
||||
{
|
||||
// Authors information
|
||||
const char *authors[] = {
|
||||
"Dale Clack",
|
||||
"GCR_CMake on github https://github.com/Makman2/GCR_CMake",
|
||||
NULL};
|
||||
|
||||
//Version information
|
||||
char *version;
|
||||
version = g_strdup_printf("5.0\nRunning Against: Gtkmm %d.%d.%d",
|
||||
GTKMM_MAJOR_VERSION,
|
||||
GTKMM_MINOR_VERSION,
|
||||
GTKMM_MICRO_VERSION);
|
||||
|
||||
// Get Year information
|
||||
time_t t;
|
||||
t=time(NULL);
|
||||
struct tm * local;
|
||||
local = localtime(&t);
|
||||
|
||||
//Copyright
|
||||
char * copyright;
|
||||
copyright = g_strdup_printf("© 2019—%04d The Xe Project",local->tm_year+1900);
|
||||
|
||||
//Show the about dialog
|
||||
gtk_show_about_dialog(GTK_WINDOW(gobj()),
|
||||
"program-name", "My_GtkUI",
|
||||
"version", version,
|
||||
"copyright", copyright,
|
||||
"comments", "A program that simulates desktop (Mac Version)",
|
||||
"authors", authors,
|
||||
"license-type", GTK_LICENSE_GPL_3_0,
|
||||
"logo-icon-name", "My_GtkUI",
|
||||
"title", "About My GtkUI Mac Version",
|
||||
NULL);
|
||||
|
||||
//Free Memory
|
||||
g_free(version);
|
||||
g_free(copyright);
|
||||
}
|
||||
|
||||
void MyWin::quit_activated()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
|
|
@ -23,5 +23,6 @@ private:
|
|||
//Signal Handlers
|
||||
void logout_activated();
|
||||
void quit_activated();
|
||||
void about_activated();
|
||||
|
||||
};
|
|
@ -67,15 +67,15 @@ MyFinder::MyFinder()
|
|||
calender.set_margin_start(5);
|
||||
calender.set_margin_end(5);
|
||||
|
||||
//Menu button
|
||||
// Menu button
|
||||
menu_button.set_image_from_icon_name("open-menu");
|
||||
menu_button.set_relief(Gtk::RELIEF_NONE);
|
||||
pack_end(menu_button,Gtk::PACK_SHRINK);
|
||||
pack_end(menu_button, Gtk::PACK_SHRINK);
|
||||
|
||||
//Find Button
|
||||
// Find Button
|
||||
find_button.set_image_from_icon_name("finder-find");
|
||||
find_button.set_relief(Gtk::RELIEF_NONE);
|
||||
pack_end(find_button,Gtk::PACK_SHRINK);
|
||||
pack_end(find_button, Gtk::PACK_SHRINK);
|
||||
|
||||
// Timer
|
||||
timer_button.set_label("2022/1/23 18:32");
|
||||
|
@ -85,31 +85,31 @@ MyFinder::MyFinder()
|
|||
|
||||
mytimer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &MyFinder::time_out), 1000);
|
||||
|
||||
//finder-battery Button
|
||||
// finder-battery Button
|
||||
battery_button.set_image_from_icon_name("finder-battery");
|
||||
battery_button.set_relief(Gtk::RELIEF_NONE);
|
||||
pack_end(battery_button,Gtk::PACK_SHRINK);
|
||||
pack_end(battery_button, Gtk::PACK_SHRINK);
|
||||
|
||||
//NetWork Button
|
||||
// NetWork Button
|
||||
network_button.set_image_from_icon_name("finder-wifi");
|
||||
network_button.set_relief(Gtk::RELIEF_NONE);
|
||||
pack_end(network_button,Gtk::PACK_SHRINK);
|
||||
pack_end(network_button, Gtk::PACK_SHRINK);
|
||||
|
||||
//Audio Button
|
||||
// Audio Button
|
||||
audio_button.set_image_from_icon_name("finder_audio");
|
||||
audio_button.set_relief(Gtk::RELIEF_NONE);
|
||||
pack_end(audio_button,Gtk::PACK_SHRINK);
|
||||
pack_end(audio_button, Gtk::PACK_SHRINK);
|
||||
|
||||
//Monitor Button
|
||||
// Monitor Button
|
||||
screen_button.set_image_from_icon_name("finder-computer");
|
||||
screen_button.set_relief(Gtk::RELIEF_NONE);
|
||||
pack_end(screen_button,Gtk::PACK_SHRINK);
|
||||
pack_end(screen_button, Gtk::PACK_SHRINK);
|
||||
|
||||
//Add Style for MyFinder
|
||||
// Add Style for MyFinder
|
||||
provider = Gtk::CssProvider::create();
|
||||
provider->load_from_resource("/org/gtk/daleclack/style.css");
|
||||
auto style = get_style_context();
|
||||
style->add_provider(provider,G_MAXUINT);
|
||||
style->add_provider(provider, G_MAXUINT);
|
||||
}
|
||||
|
||||
bool MyFinder::time_out()
|
||||
|
|
Loading…
Reference in New Issue