Add gtk143

This commit is contained in:
daleclack 2022-12-05 23:30:18 +08:00
parent ae1934b9ac
commit 79809f74db
9 changed files with 53 additions and 8 deletions

View File

@ -13,6 +13,7 @@
</item>
<item>
<attribute name="label">About</attribute>
<attribute name="action">win.about_win1</attribute>
</item>
</submenu>
<submenu>

View File

@ -8,9 +8,13 @@
<attribute name="action">win.new_win2</attribute>
</item>
<item>
<attribute name="label">About</attribute>
<attribute name="label">Quit</attribute>
<attribute name="action">win.quit_win2</attribute>
</item>
<item>
<attribute name="label">About</attribute>
<attribute name="action">win.about_win2</attribute>
</item>
</submenu>
<submenu>
<attribute name="label">Test3</attribute>

View File

@ -21,6 +21,8 @@ MenuWin::MenuWin()
add_action("quit_win1", sigc::mem_fun(*this, &MenuWin::quit_win1));
add_action("new_win2", sigc::mem_fun(*this, &MenuWin::new_win2));
add_action("quit_win2", sigc::mem_fun(*this, &MenuWin::quit_win2));
add_action("about_win1", sigc::mem_fun(*this, &MenuWin::show_about_win1));
add_action("about_win2", sigc::mem_fun(*this, &MenuWin::show_about_win2));
// Add popover menu bar
//menu_bar = new Gtk::PopoverMenuBar(model_default);
@ -116,4 +118,13 @@ bool MenuWin::win2_closed(){
window2.hide();
menu_bar.change_menu(WinShown::DEFAULT);
return true;
}
}
// Test to interact to the child class by global menu
void MenuWin::show_about_win1(){
window1.about_win1();
}
void MenuWin::show_about_win2(){
window2.about_win2();
}

View File

@ -31,4 +31,6 @@ private:
void new_win2();
void quit_win2();
bool win2_closed();
void show_about_win1();
void show_about_win2();
};

View File

@ -1,8 +1,14 @@
#include "Win1.hh"
#include "MenuWin.hh"
#include <iostream>
extern WinShown curr_win;
Win1::Win1(){
// Add action
}
void Win1::about_win1(){
std::cout << "Window 1" << std::endl;
}

View File

@ -2,7 +2,11 @@
#include <gtkmm.h>
class Win1 : public Gtk::ApplicationWindow{
public:
class Win1 : public Gtk::ApplicationWindow
{
public:
Win1();
void about_win1();
private:
};

View File

@ -1,8 +1,13 @@
#include "Win2.hh"
#include "MenuWin.hh"
#include <iostream>
extern WinShown curr_win;
Win2::Win2(){
}
void Win2::about_win2(){
std::cout << "Window 2" << std::endl;
}

View File

@ -2,7 +2,11 @@
#include <gtkmm.h>
class Win2 : public Gtk::ApplicationWindow{
public:
Win2();
class Win2 : public Gtk::ApplicationWindow
{
public:
Win2();
void about_win2();
private:
};

View File

@ -1,5 +1,13 @@
#include "MenuWin.hh"
/*
This is a test for fake global menu,
the project exist because the GtkPopoverMenuBar can't read by appmenu-gtk module.
I don't know the reason for that, but it may be a interesting idea to
add fake global menu for My Gtk UI.
Written by dale clack, 2022/12/5
*/
int main(int argc, char **argv){
// Create a application
auto app = Gtk::Application::create("org.gtk.daleclack");