mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement separated tab label class
This commit is contained in:
parent
6e115ca3c1
commit
88e5ba3736
6 changed files with 87 additions and 46 deletions
1
Makefile
1
Makefile
|
|
@ -12,6 +12,7 @@ SRCS = src/main.cpp\
|
||||||
src/app/browser/header/tab.cpp\
|
src/app/browser/header/tab.cpp\
|
||||||
src/app/browser/main.cpp\
|
src/app/browser/main.cpp\
|
||||||
src/app/browser/main/tab.cpp\
|
src/app/browser/main/tab.cpp\
|
||||||
|
src/app/browser/main/tab/label.cpp\
|
||||||
src/lib/database.cpp\
|
src/lib/database.cpp\
|
||||||
src/lib/database/session.cpp
|
src/lib/database/session.cpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ src/app/browser/header/menu.cpp
|
||||||
src/app/browser/header/tab.cpp
|
src/app/browser/header/tab.cpp
|
||||||
src/app/browser/main.cpp
|
src/app/browser/main.cpp
|
||||||
src/app/browser/main/tab.cpp
|
src/app/browser/main/tab.cpp
|
||||||
|
src/app/browser/main/tab/label.cpp
|
||||||
src/lib/database.cpp
|
src/lib/database.cpp
|
||||||
src/lib/database/session.cpp
|
src/lib/database/session.cpp
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "tab.hpp"
|
#include "tab.hpp"
|
||||||
|
#include "tab/label.hpp"
|
||||||
|
|
||||||
using namespace app::browser::main;
|
using namespace app::browser::main;
|
||||||
|
|
||||||
|
|
@ -17,35 +18,14 @@ void Tab::append(
|
||||||
bool focus
|
bool focus
|
||||||
) {
|
) {
|
||||||
// Init new tab label
|
// Init new tab label
|
||||||
Gtk::Label * name = new Gtk::Label(
|
label = new tab::Label();
|
||||||
_("New tab")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Setup label controller
|
|
||||||
auto controller = Gtk::GestureClick::create();
|
|
||||||
|
|
||||||
/* @TODO remove as default
|
|
||||||
controller->set_button(
|
|
||||||
GDK_BUTTON_PRIMARY
|
|
||||||
);*/
|
|
||||||
|
|
||||||
controller->signal_pressed().connect(
|
|
||||||
sigc::mem_fun(
|
|
||||||
* this,
|
|
||||||
& Tab::on_label_click
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
name->add_controller(
|
|
||||||
controller
|
|
||||||
);
|
|
||||||
|
|
||||||
// Init tab data container @TODO
|
// Init tab data container @TODO
|
||||||
Gtk::Label * data = new Gtk::Label("data");
|
Gtk::Label * data = new Gtk::Label("data");
|
||||||
|
|
||||||
append_page(
|
append_page(
|
||||||
* data,
|
* data,
|
||||||
* name
|
* label
|
||||||
);
|
);
|
||||||
|
|
||||||
set_tab_reorderable(
|
set_tab_reorderable(
|
||||||
|
|
@ -88,17 +68,4 @@ void Tab::close_all()
|
||||||
-1 // active
|
-1 // active
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Tab::on_label_click(
|
|
||||||
int n,
|
|
||||||
double x,
|
|
||||||
double y
|
|
||||||
) {
|
|
||||||
if (n == 2) // double click
|
|
||||||
{
|
|
||||||
close(
|
|
||||||
-1 // active
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,24 +2,21 @@
|
||||||
#define APP_BROWSER_MAIN_TAB_HPP
|
#define APP_BROWSER_MAIN_TAB_HPP
|
||||||
|
|
||||||
#include <glibmm/i18n.h>
|
#include <glibmm/i18n.h>
|
||||||
#include <gtkmm/gestureclick.h>
|
|
||||||
#include <gtkmm/label.h>
|
|
||||||
#include <gtkmm/notebook.h>
|
#include <gtkmm/notebook.h>
|
||||||
|
|
||||||
namespace app::browser::main
|
namespace app::browser::main
|
||||||
{
|
{
|
||||||
|
namespace tab
|
||||||
|
{
|
||||||
|
class Label;
|
||||||
|
}
|
||||||
|
|
||||||
class Tab : public Gtk::Notebook
|
class Tab : public Gtk::Notebook
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
void on_label_click(
|
|
||||||
int n,
|
|
||||||
double x,
|
|
||||||
double y
|
|
||||||
);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
tab::Label * label;
|
||||||
|
|
||||||
Tab();
|
Tab();
|
||||||
|
|
||||||
~Tab();
|
~Tab();
|
||||||
|
|
|
||||||
44
src/app/browser/main/tab/label.cpp
Normal file
44
src/app/browser/main/tab/label.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "label.hpp"
|
||||||
|
|
||||||
|
using namespace app::browser::main::tab;
|
||||||
|
|
||||||
|
Label::Label()
|
||||||
|
{
|
||||||
|
set_text(
|
||||||
|
_("New tab")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Setup label controller
|
||||||
|
controller = Gtk::GestureClick::create();
|
||||||
|
|
||||||
|
/* @TODO remove as default
|
||||||
|
controller->set_button(
|
||||||
|
GDK_BUTTON_PRIMARY
|
||||||
|
);*/
|
||||||
|
|
||||||
|
controller->signal_pressed().connect(
|
||||||
|
sigc::mem_fun(
|
||||||
|
* this,
|
||||||
|
& Label::on_click
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
add_controller(
|
||||||
|
controller
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Label::~Label() = default;
|
||||||
|
|
||||||
|
void Label::on_click(
|
||||||
|
int n,
|
||||||
|
double x,
|
||||||
|
double y
|
||||||
|
) {
|
||||||
|
if (n == 2) // double click
|
||||||
|
{
|
||||||
|
//Tab::close(
|
||||||
|
// -1 // active
|
||||||
|
//);
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/app/browser/main/tab/label.hpp
Normal file
31
src/app/browser/main/tab/label.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef APP_BROWSER_MAIN_TAB_LABEL_HPP
|
||||||
|
#define APP_BROWSER_MAIN_TAB_LABEL_HPP
|
||||||
|
|
||||||
|
#include <glibmm/i18n.h>
|
||||||
|
#include <glibmm/refptr.h>
|
||||||
|
#include <gtkmm/gestureclick.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
|
||||||
|
namespace app::browser::main::tab
|
||||||
|
{
|
||||||
|
class Label : public Gtk::Label
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
Glib::RefPtr<Gtk::GestureClick> controller;
|
||||||
|
|
||||||
|
void on_click(
|
||||||
|
int n,
|
||||||
|
double x,
|
||||||
|
double y
|
||||||
|
);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Label();
|
||||||
|
|
||||||
|
~Label();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // APP_BROWSER_MAIN_TAB_LABEL_HPP
|
||||||
Loading…
Add table
Add a link
Reference in a new issue