mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement debug menu item
This commit is contained in:
parent
58c978184c
commit
6b1c3b84ee
5 changed files with 154 additions and 2 deletions
1
Makefile
1
Makefile
|
|
@ -15,6 +15,7 @@ SRCS = src/main.cpp\
|
||||||
src/app/browser/header/bar/title.cpp\
|
src/app/browser/header/bar/title.cpp\
|
||||||
src/app/browser/header/bar/menu.cpp\
|
src/app/browser/header/bar/menu.cpp\
|
||||||
src/app/browser/header/bar/menu/main.cpp\
|
src/app/browser/header/bar/menu/main.cpp\
|
||||||
|
src/app/browser/header/bar/menu/main/debug.cpp\
|
||||||
src/app/browser/header/bar/menu/main/quit.cpp
|
src/app/browser/header/bar/menu/main/quit.cpp
|
||||||
|
|
||||||
OBJS = $(SRCS:.cpp=.o)
|
OBJS = $(SRCS:.cpp=.o)
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,24 @@ namespace app::browser::header::bar::menu
|
||||||
// Init dependencies
|
// Init dependencies
|
||||||
this->menu = menu;
|
this->menu = menu;
|
||||||
|
|
||||||
// Init GMenu Model
|
// Init model
|
||||||
this->_model = g_menu_new();
|
this->_model = g_menu_new();
|
||||||
|
|
||||||
// Init menu items
|
// Init debug menu
|
||||||
|
this->debug = new main::Debug(
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
g_menu_append_item(
|
||||||
|
G_MENU(
|
||||||
|
this->_model
|
||||||
|
),
|
||||||
|
G_MENU_ITEM(
|
||||||
|
this->debug->item
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Init quit menu
|
||||||
this->quit = new main::Quit(
|
this->quit = new main::Quit(
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../menu.h"
|
#include "../menu.h"
|
||||||
|
|
||||||
// Requirements
|
// Requirements
|
||||||
|
#include "main/debug.h"
|
||||||
#include "main/quit.h"
|
#include "main/quit.h"
|
||||||
|
|
||||||
namespace app::browser::header::bar
|
namespace app::browser::header::bar
|
||||||
|
|
@ -15,6 +16,7 @@ namespace app::browser::header::bar
|
||||||
{
|
{
|
||||||
namespace main
|
namespace main
|
||||||
{
|
{
|
||||||
|
class Debug;
|
||||||
class Quit;
|
class Quit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -33,6 +35,7 @@ namespace app::browser::header::bar
|
||||||
Menu *menu;
|
Menu *menu;
|
||||||
|
|
||||||
// Requirements
|
// Requirements
|
||||||
|
main::Debug *debug;
|
||||||
main::Quit *quit;
|
main::Quit *quit;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
|
||||||
84
src/app/browser/header/bar/menu/main/debug.cpp
Normal file
84
src/app/browser/header/bar/menu/main/debug.cpp
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
namespace app::browser::header::bar::menu::main
|
||||||
|
{
|
||||||
|
// Construct
|
||||||
|
Debug::Debug(
|
||||||
|
Main *main
|
||||||
|
) {
|
||||||
|
// Init dependencies
|
||||||
|
this->main = main;
|
||||||
|
|
||||||
|
// Init action object
|
||||||
|
this->action = g_simple_action_new(
|
||||||
|
Debug::ACTION_ID,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
g_action_map_add_action(
|
||||||
|
G_ACTION_MAP(
|
||||||
|
this->main->menu->bar->header->browser->app
|
||||||
|
),
|
||||||
|
G_ACTION(
|
||||||
|
this->action
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Init action NS
|
||||||
|
gchar action[255];
|
||||||
|
|
||||||
|
g_snprintf(
|
||||||
|
action,
|
||||||
|
sizeof(
|
||||||
|
action
|
||||||
|
),
|
||||||
|
Debug::ACTION_NS,
|
||||||
|
Debug::ACTION_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
// Init keyboard accelerators
|
||||||
|
// https://docs.gtk.org/gtk4/func.accelerator_parse.html
|
||||||
|
const gchar *accels[] = {
|
||||||
|
Debug::ACCEL_1, // First accelerator
|
||||||
|
Debug::ACCEL_2, // Second accelerator
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
gtk_application_set_accels_for_action(
|
||||||
|
GTK_APPLICATION(
|
||||||
|
this->main->menu->bar->header->browser->app
|
||||||
|
),
|
||||||
|
action,
|
||||||
|
accels
|
||||||
|
);
|
||||||
|
|
||||||
|
// Init menu item object
|
||||||
|
this->item = g_menu_item_new(
|
||||||
|
Debug::LABEL,
|
||||||
|
action
|
||||||
|
);
|
||||||
|
|
||||||
|
// Connect events
|
||||||
|
g_signal_connect(
|
||||||
|
G_SIMPLE_ACTION(
|
||||||
|
this->action
|
||||||
|
),
|
||||||
|
"activate",
|
||||||
|
G_CALLBACK(
|
||||||
|
Debug::_activate
|
||||||
|
),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Events
|
||||||
|
void Debug::_activate(
|
||||||
|
GSimpleAction* action,
|
||||||
|
GVariant* parameter,
|
||||||
|
gpointer user_data
|
||||||
|
) {
|
||||||
|
gtk_window_set_interactive_debugging(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
src/app/browser/header/bar/menu/main/debug.h
Normal file
50
src/app/browser/header/bar/menu/main/debug.h
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef APP_BROWSER_HEADER_BAR_MENU_DEBUG_H
|
||||||
|
#define APP_BROWSER_HEADER_BAR_MENU_DEBUG_H
|
||||||
|
|
||||||
|
#include "../main.h"
|
||||||
|
|
||||||
|
namespace app::browser::header::bar::menu
|
||||||
|
{
|
||||||
|
class Main;
|
||||||
|
|
||||||
|
namespace main
|
||||||
|
{
|
||||||
|
class Debug
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// GTK
|
||||||
|
GMenuItem *item;
|
||||||
|
|
||||||
|
GSimpleAction *action;
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
Main *main;
|
||||||
|
|
||||||
|
// Defaults
|
||||||
|
const gchar *LABEL = "Debug";
|
||||||
|
|
||||||
|
const gchar *ACCEL_1 = "<Control><Shift>i";
|
||||||
|
const gchar *ACCEL_2 = "<Control><Shift>I";
|
||||||
|
|
||||||
|
const gchar *ACTION_NS = "app.%s";
|
||||||
|
const gchar *ACTION_ID = "browser.header.bar.menu.main.debug.activate";
|
||||||
|
|
||||||
|
// Construct
|
||||||
|
Debug(
|
||||||
|
Main *main
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Events
|
||||||
|
static void _activate(
|
||||||
|
GSimpleAction* action,
|
||||||
|
GVariant* parameter,
|
||||||
|
gpointer user_data
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue