aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--css/style.css119
m---------depends/odhtdb0
-rw-r--r--include/ChatMessage.hpp16
-rw-r--r--include/ChatWindow.hpp29
-rw-r--r--include/LoginWindow.hpp21
-rw-r--r--include/Window.hpp20
-rw-r--r--project.conf2
-rwxr-xr-xrun.sh3
-rw-r--r--src/ChatMessage.cpp22
-rw-r--r--src/ChatWindow.cpp106
-rw-r--r--src/LoginWindow.cpp56
-rw-r--r--src/Window.cpp25
-rw-r--r--src/main.cpp52
14 files changed, 465 insertions, 9 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..8fd227f
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "depends/odhtdb"]
+ path = depends/odhtdb
+ url = https://gitlab.com/DEC05EBA/odhtdb.git
diff --git a/css/style.css b/css/style.css
new file mode 100644
index 0000000..d07b4c4
--- /dev/null
+++ b/css/style.css
@@ -0,0 +1,119 @@
+window {
+ background-color: #2f3136;
+}
+
+entry {
+ caret-color: #f7f7f7;
+ background-color: #444444;
+ border-color: #444444;
+ border-radius: 10px;
+ color: #f7f7f7;
+ box-shadow: 0px 0px 0px 0px;
+}
+
+label {
+ color: #f7f7f7;
+}
+
+button {
+ background-image: none;
+ background-color: #2f3136;
+ color: #f7f7f7;
+ border-style: none;
+}
+
+#side-panels separator {
+ border: 1px solid #2f3136;
+}
+
+#top-bar {
+ background-color: #36393e;
+ box-shadow: 0px 0px 5px #1d1d1d;
+ padding: 10px 10px 10px 10px;
+}
+
+#current-channel-title {
+ color: #f7f7f7;
+ font-size: 20px;
+ font-weight: bold;
+}
+
+#left-panel {
+ background-color: #36393e;
+ padding: 10px 10px 10px 10px;
+ border: 1px solid #36393e;
+ /*
+ margin-right: 20px;
+ box-shadow: 0px 0px 5px #1d1d1d;
+ */
+}
+
+#channels-title {
+ color: #f7f7f7;
+ font-weight: bold;
+ font-size: 16px;
+}
+
+#users-title {
+ color: #f7f7f7;
+ font-weight: bold;
+ font-size: 16px;
+}
+
+#chat-panel {
+ background-color: #444444;
+}
+
+#chat-area-layout {
+ margin-top: 10px;
+ margin-bottom: 10px;
+}
+
+.chat-message {
+ color: white;
+ background-color: #36393e;
+ padding: 15px 15px 15px 15px;
+ margin: 10px 20px 10px 20px;
+ box-shadow: 0px 0px 5px #1d1d1d;
+}
+
+.chat-message-username {
+ color: #0fc0fc;
+}
+
+textview {
+ caret-color: #f7f7f7;
+}
+
+textview text {
+ background-color: #444444;
+ color: #f7f7f7;
+}
+
+.login-window {
+ background-color: #36393e;
+ border: 5px solid #36393e;
+ border-radius: 7px;
+ padding: 2em;
+}
+
+/*
+#chat-input {
+ border-style: none;
+ caret-color: #f7f7f7;
+}
+
+#chat-input selection {
+ background-color: red;
+}
+*/
+
+#chat-scroll-view {
+ background-color: #444444;
+ /*padding: 10px 10px 10px 10px;*/
+}
+/*
+#chat-input {
+ padding: 10px 10px 10px 10px;
+}
+*/ \ No newline at end of file
diff --git a/depends/odhtdb b/depends/odhtdb
new file mode 160000
+Subproject 109108c896f1ada76121330ab01602072f32dd8
diff --git a/include/ChatMessage.hpp b/include/ChatMessage.hpp
new file mode 100644
index 0000000..0547557
--- /dev/null
+++ b/include/ChatMessage.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <gtkmm/grid.h>
+#include <gtkmm/label.h>
+
+namespace dchat
+{
+ class ChatMessage : public Gtk::Grid
+ {
+ public:
+ ChatMessage(const Glib::ustring &username, const Glib::ustring &text);
+
+ Gtk::Label username;
+ Gtk::Label text;
+ };
+} \ No newline at end of file
diff --git a/include/ChatWindow.hpp b/include/ChatWindow.hpp
new file mode 100644
index 0000000..2d45b76
--- /dev/null
+++ b/include/ChatWindow.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <gtkmm/label.h>
+#include <gtkmm/grid.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/stack.h>
+#include <gtkmm/textview.h>
+
+namespace dchat
+{
+ class ChatWindow : public Gtk::Grid
+ {
+ public:
+ ChatWindow();
+ private:
+ void setupTopBar();
+ void setupLeftPanel(Gtk::Paned *sidePanels);
+ void setupMessageArea(Gtk::Grid *rightPanel);
+ void setupChatInput(Gtk::Grid *rightPanel);
+ private:
+ Gtk::Grid topbar;
+ Gtk::Entry topbarSearchBar;
+ Gtk::Label currentChannelTitle;
+ Gtk::ScrolledWindow chatArea;
+ Gtk::TextView chatInput;
+ };
+} \ No newline at end of file
diff --git a/include/LoginWindow.hpp b/include/LoginWindow.hpp
new file mode 100644
index 0000000..b60dddb
--- /dev/null
+++ b/include/LoginWindow.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <gtkmm/grid.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#include <functional>
+
+namespace dchat
+{
+ class LoginWindow : public Gtk::Grid
+ {
+ public:
+ LoginWindow();
+
+ void setLoginHandler(std::function<void()> loginHandler);
+ private:
+ Gtk::Entry usernameInput;
+ Gtk::Entry passwordInput;
+ Gtk::Button loginButton;
+ };
+} \ No newline at end of file
diff --git a/include/Window.hpp b/include/Window.hpp
new file mode 100644
index 0000000..2810bbd
--- /dev/null
+++ b/include/Window.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "ChatWindow.hpp"
+#include "LoginWindow.hpp"
+#include <gtkmm/window.h>
+#include <gtkmm/stack.h>
+
+namespace dchat
+{
+ class Window : public Gtk::Window
+ {
+ public:
+ Window();
+ virtual ~Window();
+ protected:
+ Gtk::Stack stack;
+ LoginWindow loginWindow;
+ ChatWindow chatWindow;
+ };
+} \ No newline at end of file
diff --git a/project.conf b/project.conf
index 03785d9..a92579e 100644
--- a/project.conf
+++ b/project.conf
@@ -1,5 +1,5 @@
[package]
-name = "online_persona_gtk"
+name = "dchat"
type = "executable"
version = "0.1.0"
platforms = ["any"]
diff --git a/run.sh b/run.sh
new file mode 100755
index 0000000..116f665
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+env GTK_THEME="css/style.css" ./sibs-build/debug/dchat
diff --git a/src/ChatMessage.cpp b/src/ChatMessage.cpp
new file mode 100644
index 0000000..6dbd671
--- /dev/null
+++ b/src/ChatMessage.cpp
@@ -0,0 +1,22 @@
+#include "../include/ChatMessage.hpp"
+
+namespace dchat
+{
+ ChatMessage::ChatMessage(const Glib::ustring &_username, const Glib::ustring &_text) :
+ username(_username),
+ text(_text)
+ {
+ username.set_selectable(true);
+ username.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);
+ username.get_style_context()->add_class("chat-message-username");
+
+ text.set_selectable(true);
+ text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);
+ text.set_line_wrap_mode(Pango::WRAP_WORD_CHAR);
+ text.get_style_context()->add_class("chat-message-text");
+
+ attach(username, 0, 0, 1, 1);
+ attach(text, 0, 1, 1, 1);
+ get_style_context()->add_class("chat-message");
+ }
+} \ No newline at end of file
diff --git a/src/ChatWindow.cpp b/src/ChatWindow.cpp
new file mode 100644
index 0000000..a428d0b
--- /dev/null
+++ b/src/ChatWindow.cpp
@@ -0,0 +1,106 @@
+#include "../include/ChatWindow.hpp"
+#include "../include/ChatMessage.hpp"
+#include <gtkmm/alignment.h>
+
+namespace dchat
+{
+ ChatWindow::ChatWindow()
+ {
+ setupTopBar();
+
+ Gtk::Paned *sidePanels = Gtk::manage(new Gtk::Paned());
+ sidePanels->set_name("side-panels");
+ sidePanels->set_border_width(0);
+ attach(*sidePanels, 0, 1, 1, 2);
+
+ setupLeftPanel(sidePanels);
+
+ Gtk::Grid *rightPanel = Gtk::manage(new Gtk::Grid());
+ rightPanel->set_hexpand(true);
+ sidePanels->add2(*rightPanel);
+
+ setupMessageArea(rightPanel);
+ setupChatInput(rightPanel);
+
+ set_vexpand(true);
+ set_hexpand(true);
+ }
+
+ void ChatWindow::setupTopBar()
+ {
+ topbar.set_name("top-bar");
+ topbar.set_hexpand(true);
+ attach(topbar, 0, 0, 2, 1);
+
+ topbarSearchBar.set_size_request(175);
+ topbarSearchBar.set_name("top-bar-search");
+ topbarSearchBar.set_placeholder_text("Search...");
+ topbar.attach(topbarSearchBar, 0, 0, 1, 1);
+
+ Gtk::Alignment *topbarSpacer = Gtk::manage(new Gtk::Alignment());
+ topbarSpacer->set_size_request(50);
+ topbar.attach_next_to(*topbarSpacer, topbarSearchBar, Gtk::POS_RIGHT, 1, 1);
+
+ currentChannelTitle.set_text("Linux");
+ currentChannelTitle.set_name("current-channel-title");
+ topbar.attach_next_to(currentChannelTitle, *topbarSpacer, Gtk::POS_RIGHT, 1, 1);
+ }
+
+ void ChatWindow::setupLeftPanel(Gtk::Paned *sidePanels)
+ {
+ Gtk::Paned *leftPanel = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL));
+ leftPanel->set_size_request(200);
+ leftPanel->set_name("left-panel");
+ leftPanel->set_vexpand(true);
+ sidePanels->add1(*leftPanel);
+
+ Gtk::Grid *leftPanelChannels = Gtk::manage(new Gtk::Grid());
+ leftPanelChannels->set_vexpand(true);
+ leftPanel->add1(*leftPanelChannels);
+
+ Gtk::Label *channelsTitle = Gtk::manage(new Gtk::Label());
+ channelsTitle->set_name("channels-title");
+ channelsTitle->set_text("Channels");
+ leftPanelChannels->attach(*channelsTitle, 0, 0, 1, 1);
+
+ ////
+ Gtk::Grid *leftPanelUsers = Gtk::manage(new Gtk::Grid());
+ leftPanelUsers->set_vexpand(true);
+ leftPanel->add2(*leftPanelUsers);
+
+ Gtk::Label *usersTitle = Gtk::manage(new Gtk::Label());
+ usersTitle->set_name("users-title");
+ usersTitle->set_text("Users");
+ leftPanelUsers->attach(*usersTitle, 0, 0, 1, 1);
+ }
+
+ void ChatWindow::setupMessageArea(Gtk::Grid *rightPanel)
+ {
+ chatArea.set_vexpand(true);
+ rightPanel->attach(chatArea, 0, 0, 1, 2);
+
+ Gtk::Grid *chatAreaLayout = Gtk::manage(new Gtk::Grid());
+ chatAreaLayout->set_name("chat-area-layout");
+ chatArea.add(*chatAreaLayout);
+
+ for(int i = 0; i < 100; ++i)
+ {
+ ChatMessage *message = Gtk::manage(new ChatMessage("Arezu", "hellooooo" + std::to_string(i)));
+ message->set_valign(Gtk::Align::ALIGN_START);
+ message->set_hexpand(true);
+ chatAreaLayout->attach(*message, 0, i, 1, 1);
+ }
+ }
+
+ void ChatWindow::setupChatInput(Gtk::Grid *rightPanel)
+ {
+ Gtk::ScrolledWindow *chatScrollWindow = Gtk::manage(new Gtk::ScrolledWindow());
+ chatScrollWindow->set_name("chat-scroll-view");
+ rightPanel->attach_next_to(*chatScrollWindow, chatArea, Gtk::POS_BOTTOM, 1, 1);
+
+ chatInput.set_hexpand(true);
+ chatInput.set_name("chat-input");
+ chatInput.set_wrap_mode(Gtk::WrapMode::WRAP_WORD_CHAR);
+ chatScrollWindow->add(chatInput);
+ }
+} \ No newline at end of file
diff --git a/src/LoginWindow.cpp b/src/LoginWindow.cpp
new file mode 100644
index 0000000..4232982
--- /dev/null
+++ b/src/LoginWindow.cpp
@@ -0,0 +1,56 @@
+#include "../include/LoginWindow.hpp"
+#include <gtkmm/label.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/alignment.h>
+#include <gtkmm/button.h>
+#include <cassert>
+
+namespace dchat
+{
+ LoginWindow::LoginWindow() :
+ loginButton("Login")
+ {
+ Gtk::Label *username = Gtk::manage(new Gtk::Label());
+ username->set_text("Username");
+ username->set_halign(Gtk::ALIGN_START);
+ attach(*username, 0, 0, 1, 1);
+
+ usernameInput.set_size_request(200);
+ attach_next_to(usernameInput, *username, Gtk::POS_BOTTOM, 3, 1);
+
+ Gtk::Alignment *usernamePasswordSpacer = Gtk::manage(new Gtk::Alignment());
+ usernamePasswordSpacer->set_size_request(-1, 35);
+ attach_next_to(*usernamePasswordSpacer, usernameInput, Gtk::POS_BOTTOM, 1, 1);
+
+ Gtk::Label *password = Gtk::manage(new Gtk::Label());
+ password->set_text("Password");
+ password->set_halign(Gtk::ALIGN_START);
+ attach_next_to(*password, *usernamePasswordSpacer, Gtk::POS_BOTTOM, 1, 1);
+
+ passwordInput.set_visibility(false);
+ passwordInput.set_size_request(200);
+ attach_next_to(passwordInput, *password, Gtk::POS_BOTTOM, 3, 1);
+
+ Gtk::Alignment *loginButtonSpacerTop = Gtk::manage(new Gtk::Alignment());
+ loginButtonSpacerTop->set_size_request(-1, 20);
+ attach_next_to(*loginButtonSpacerTop, passwordInput, Gtk::POS_BOTTOM, 1, 1);
+
+ Gtk::Alignment *loginButtonSpacer = Gtk::manage(new Gtk::Alignment());
+ attach_next_to(*loginButtonSpacer, *loginButtonSpacerTop, Gtk::POS_BOTTOM, 2, 1);
+
+ loginButton.set_halign(Gtk::ALIGN_END);
+ attach_next_to(loginButton, *loginButtonSpacer, Gtk::POS_RIGHT, 1, 1);
+
+ set_halign(Gtk::ALIGN_CENTER);
+ set_valign(Gtk::ALIGN_CENTER);
+ get_style_context()->add_class("login-window");
+ }
+
+ void LoginWindow::setLoginHandler(std::function<void()> loginHandler)
+ {
+ assert(loginHandler);
+ usernameInput.signal_activate().connect(loginHandler);
+ passwordInput.signal_activate().connect(loginHandler);
+ loginButton.signal_clicked().connect(loginHandler);
+ }
+} \ No newline at end of file
diff --git a/src/Window.cpp b/src/Window.cpp
new file mode 100644
index 0000000..c912130
--- /dev/null
+++ b/src/Window.cpp
@@ -0,0 +1,25 @@
+#include "../include/Window.hpp"
+
+namespace dchat
+{
+ Window::Window()
+ {
+ set_border_width(0);
+ add(stack);
+
+ stack.add(loginWindow, "login");
+ stack.add(chatWindow, "chat");
+
+ show_all_children();
+
+ loginWindow.setLoginHandler([]
+ {
+ printf("login!\n");
+ });
+ }
+
+ Window::~Window()
+ {
+
+ }
+} \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index e085836..d83fd27 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,13 +1,49 @@
-#include <gtkmm.h>
+#include "../include/Window.hpp"
+#include <gtkmm/application.h>
+#include <gtkmm/cssprovider.h>
+#include <odhtdb/Database.hpp>
-int main(int argc, char *argv[])
+int main (int argc, char *argv[])
{
- auto app =
- Gtk::Application::create(argc, argv,
- "org.gtkmm.examples.base");
+ auto app = Gtk::Application::create(argc, argv, "dec05eba.dchat");
- Gtk::Window window;
- window.set_default_size(200, 200);
+ auto css = Gtk::CssProvider::create();
+ try
+ {
+ if(!css->load_from_path("css/style.css"))
+ {
+ fprintf(stderr, "Failed to load css/style.css");
+ return 1;
+ }
+ }
+ catch(Gtk::CssProviderError &e)
+ {
+ fprintf(stderr, "Failed to load css/style.css, error: %s\n", e.what().c_str());
+ return 1;
+ }
- return app->run(window);
+ dchat::Window window;
+ auto ctx = window.get_style_context();
+ auto screen = Gdk::Screen::get_default();
+ ctx->add_provider_for_screen(screen, css, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ odhtdb::DatabaseCallbackFuncs callbackFuncs;
+ callbackFuncs.createNodeCallbackFunc = [](const odhtdb::DatabaseCreateNodeRequest &request)
+ {
+
+ };
+
+ callbackFuncs.addNodeCallbackFunc = [](const odhtdb::DatabaseAddNodeRequest &request)
+ {
+
+ };
+
+ callbackFuncs.addUserCallbackFunc = [](const odhtdb::DatabaseAddUserRequest &request)
+ {
+
+ };
+
+ //odhtdb::Database database("206.189.13.66", 27130, "/tmp/dchat_gtk", callbackFuncs);
+
+ return app->run(window);
}