Browse Source

implement header subtitle widget

CPP-GTK4
yggverse 3 weeks ago
parent
commit
c22b3a6b30
  1. 1
      Makefile
  2. 1
      po/POTFILES.in
  3. 22
      src/app/browser/header/main.cpp
  4. 8
      src/app/browser/header/main.hpp
  5. 36
      src/app/browser/header/main/subtitle.cpp
  6. 27
      src/app/browser/header/main/subtitle.hpp

1
Makefile

@ -9,6 +9,7 @@ SRCS = src/main.cpp\ @@ -9,6 +9,7 @@ SRCS = src/main.cpp\
src/app/browser.cpp\
src/app/browser/header.cpp\
src/app/browser/header/main.cpp\
src/app/browser/header/main/subtitle.cpp\
src/app/browser/header/main/title.cpp\
src/app/browser/header/menu.cpp\
src/app/browser/header/tab.cpp\

1
po/POTFILES.in

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
src/app/browser.cpp
src/app/browser/header.cpp
src/app/browser/header/main.cpp
src/app/browser/header/main/subtitle.cpp
src/app/browser/header/main/title.cpp
src/app/browser/header/menu.cpp
src/app/browser/header/tab.cpp

22
src/app/browser/header/main.cpp

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "main.hpp"
#include "main/title.hpp"
#include "main/subtitle.hpp"
using namespace app::browser::header;
@ -11,26 +12,33 @@ Main::Main() @@ -11,26 +12,33 @@ Main::Main()
);
set_homogeneous(
true
HOMOGENEOUS
);
// Init title
title = new main::Title();
mainTitle = new main::Title();
append(
* title
* mainTitle
);
mainSubtitle = new main::Subtitle();
append(
* mainSubtitle
);
}
Main::~Main()
{
delete title;
delete mainTitle;
delete mainSubtitle;
}
void Main::set_title(
const Glib::ustring value
const Glib::ustring & TEXT
) {
title->set(
value
mainTitle->set(
TEXT
);
}

8
src/app/browser/header/main.hpp

@ -9,11 +9,15 @@ namespace app::browser::header @@ -9,11 +9,15 @@ namespace app::browser::header
namespace main
{
class Title;
class Subtitle;
}
class Main : public Gtk::Box
{
main::Title * title;
main::Title * mainTitle;
main::Subtitle * mainSubtitle;
const bool HOMOGENEOUS = true;
public:
@ -22,7 +26,7 @@ namespace app::browser::header @@ -22,7 +26,7 @@ namespace app::browser::header
~Main();
void set_title(
const Glib::ustring text
const Glib::ustring & TEXT
);
};
}

36
src/app/browser/header/main/subtitle.cpp

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
#include "subtitle.hpp"
using namespace app::browser::header::main;
Subtitle::Subtitle()
{
add_css_class(
"subtitle"
);
set_single_line_mode(
true
);
set_ellipsize(
Pango::EllipsizeMode::END
);
set_valign(
Gtk::Align::CENTER
);
set_width_chars(
WIDTH_CHARS
);
}
Subtitle::~Subtitle() = default;
void Subtitle::set(
const Glib::ustring & TEXT
) {
set_text(
TEXT
);
}

27
src/app/browser/header/main/subtitle.hpp

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
#ifndef APP_BROWSER_HEADER_MAIN_SUBTITLE_HPP
#define APP_BROWSER_HEADER_MAIN_SUBTITLE_HPP
#include <glibmm/ustring.h>
#include <gtkmm/enums.h>
#include <gtkmm/label.h>
#include <pangomm/layout.h>
namespace app::browser::header::main
{
class Subtitle : public Gtk::Label
{
const int WIDTH_CHARS = 5;
public:
Subtitle();
~Subtitle();
void set(
const Glib::ustring & TEXT
);
};
}
#endif // APP_BROWSER_HEADER_MAIN_SUBTITLE_HPP
Loading…
Cancel
Save