Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #pragma once
- #include <algorithm>
- #include <vector>
- #include <utility>
- #pragma once
- #include <tuple>
- #include <cmath>
- #include "utils.hpp"
- #include "AbstractView.hpp"
- #include <fstream>
- #include <iostream>
- #include <chrono>
- #include <ctime>
- #include <gtk/gtk.h>
- using std::string;
- using std::cout;
- using std::endl;
- using std::cerr;
- using std::get;
- using std::min;
- using std::max;
- using std::vector;
- using std::pair;
- using std::tuple;
- class GtkImageTextView : public AbstractView {
- public:
- GtkImageTextView(){}
- void SetTextWidget(GtkWidget *text) {
- text_ = text;
- }
- void ApplyNotification(const AbstractNotification& notification) {
- if (notification.GetType() == AbstractNotification::GetNotificationType<string>()) {
- auto end = std::chrono::system_clock::now();
- std::time_t end_time = std::chrono::system_clock::to_time_t(end);
- auto string_view_date = string(std::ctime(&end_time));
- string appended = string(std::ctime(&end_time)).substr(0, (int)string_view_date.size() - 1) + "\t" + notification.GetMessage();
- AppendText(text_, appended);
- }
- }
- static void AppendText(GtkWidget* text, string append_text) {
- string new_text = string(gtk_label_get_text(GTK_LABEL(text))) + "\n" + append_text;
- {
- gchar* string_for_gtk = new gchar[new_text.size() + 1];
- strcpy(string_for_gtk, new_text.c_str());
- gtk_label_set_text(GTK_LABEL(text), string_for_gtk);
- delete[](string_for_gtk);
- }
- }
- virtual ~GtkImageTextView() {
- }
- private:
- GtkWidget* text_;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement