diff --git a/Gtkmm3_Mac/res/menubar.xml b/Gtkmm3_Mac/res/menubar.xml index 6926c67..f0180a8 100644 --- a/Gtkmm3_Mac/res/menubar.xml +++ b/Gtkmm3_Mac/res/menubar.xml @@ -4,6 +4,7 @@
About My GtkUI Mac version + win.about Software Update... diff --git a/Gtkmm3_Mac/src/core/MyWin.cc b/Gtkmm3_Mac/src/core/MyWin.cc index e1f1378..e06d2d9 100644 --- a/Gtkmm3_Mac/src/core/MyWin.cc +++ b/Gtkmm3_Mac/src/core/MyWin.cc @@ -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::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(); } diff --git a/Gtkmm3_Mac/src/core/MyWin.hh b/Gtkmm3_Mac/src/core/MyWin.hh index a5bd879..92820bf 100644 --- a/Gtkmm3_Mac/src/core/MyWin.hh +++ b/Gtkmm3_Mac/src/core/MyWin.hh @@ -23,5 +23,6 @@ private: //Signal Handlers void logout_activated(); void quit_activated(); + void about_activated(); }; \ No newline at end of file diff --git a/Gtkmm3_Mac/src/ui/MyFinder.cc b/Gtkmm3_Mac/src/ui/MyFinder.cc index 2a52fd9..a399c49 100644 --- a/Gtkmm3_Mac/src/ui/MyFinder.cc +++ b/Gtkmm3_Mac/src/ui/MyFinder.cc @@ -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() @@ -124,7 +124,7 @@ bool MyFinder::time_out() local = localtime(&t); // Format the time to show - sprintf(time_string, "%04d/%d/%d %02d:%02d:%02d", local->tm_year + 1900, local->tm_mon + 1, + sprintf(time_string, "%04d/%d/%d %02d:%02d:%02d", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec); timer_button.set_label(time_string);