Browse Source

implement debug menu item

CPP-GTK4
yggverse 3 months ago
parent
commit
cf64949986
  1. 27
      src/app/browser.cpp
  2. 6
      src/app/browser.hpp
  3. 6
      src/app/browser/header/menu.cpp
  4. 12
      src/main.cpp
  5. 4
      src/main.hpp

27
src/app/browser.cpp

@ -3,8 +3,9 @@ @@ -3,8 +3,9 @@
using namespace app;
Browser::Browser()
{
Browser::Browser(
const Glib::RefPtr<Gtk::Application> & app
) {
set_title(
TITLE
);
@ -17,4 +18,24 @@ Browser::Browser() @@ -17,4 +18,24 @@ Browser::Browser()
set_titlebar(
* new browser::Header()
);
}
add_action(
"debug",
sigc::mem_fun(
* this,
& Browser::debug
)
);
app->set_accel_for_action(
"win.debug",
"<Primary>i"
);
}
void Browser::debug()
{
gtk_window_set_interactive_debugging(
true
);
};

6
src/app/browser.hpp

@ -14,7 +14,11 @@ namespace app @@ -14,7 +14,11 @@ namespace app
const int WIDTH = 640;
const int HEIGHT = 480;
Browser();
Browser(
const Glib::RefPtr<Gtk::Application> & app
);
void debug();
};
}

6
src/app/browser/header/menu.cpp

@ -14,7 +14,7 @@ Menu::Menu() @@ -14,7 +14,7 @@ Menu::Menu()
tab->append(
_("New tab"),
"app.tab.new"
"tab.new"
);
// Build tool submenu
@ -22,7 +22,7 @@ Menu::Menu() @@ -22,7 +22,7 @@ Menu::Menu()
tool->append(
_("Debug"),
"app.tool.debug"
"win.debug"
);
// Build main menu
@ -40,7 +40,7 @@ Menu::Menu() @@ -40,7 +40,7 @@ Menu::Menu()
main->append(
_("Quit"),
"win.quit"
"app.quit"
);
set_menu_model(

12
src/main.cpp

@ -3,22 +3,23 @@ @@ -3,22 +3,23 @@
int main(
int argc,
char* argv[]
char * argv[]
) {
// Init app
auto app = Gtk::Application::create(
APPLICATION_ID
"io.github.yggverse.Yoda"
);
// Init actions
app->add_action(
"quit",
sigc::mem_fun(
*app,
&Gtk::Application::quit
* app,
& Gtk::Application::quit
)
);
// Init accels
app->set_accel_for_action(
"app.quit",
"<Primary>q"
@ -27,6 +28,7 @@ int main( @@ -27,6 +28,7 @@ int main(
// Launch browser component
return app->make_window_and_run<app::Browser>(
argc,
argv
argv,
app
);
}

4
src/main.hpp

@ -1,8 +1,6 @@ @@ -1,8 +1,6 @@
#include <glibmm.h>
const Glib::ustring APPLICATION_ID = "io.github.yggverse.Yoda";
int main(
int argc,
char* argv[]
char * argv[]
);
Loading…
Cancel
Save