Settings - font sizes
This commit is contained in:
@@ -73,6 +73,7 @@ typedef void GtkComboBox;
|
|||||||
typedef void GtkGrid;
|
typedef void GtkGrid;
|
||||||
typedef void GtkColorButton;
|
typedef void GtkColorButton;
|
||||||
typedef void GtkColorChooser;
|
typedef void GtkColorChooser;
|
||||||
|
typedef void GtkSpinButton;
|
||||||
|
|
||||||
typedef int gboolean;
|
typedef int gboolean;
|
||||||
typedef int gint;
|
typedef int gint;
|
||||||
@@ -669,6 +670,10 @@ DECL(GdkEvent*, gtk_get_current_event, (void ))
|
|||||||
DECL(void, gtk_main_do_event, (GdkEvent* event))
|
DECL(void, gtk_main_do_event, (GdkEvent* event))
|
||||||
DECL(void, gdk_event_free, (GdkEvent* event))
|
DECL(void, gdk_event_free, (GdkEvent* event))
|
||||||
|
|
||||||
|
DECL(GtkWidget*, gtk_spin_button_new_with_range, (gdouble min, gdouble max, gdouble step))
|
||||||
|
DECL(void, gtk_spin_button_set_value, (GtkSpinButton* spin_button, gdouble value ))
|
||||||
|
DECL(gint, gtk_spin_button_get_value_as_int, (GtkSpinButton* spin_button ))
|
||||||
|
|
||||||
DECL(unsigned long, g_signal_connect_data, (GObject *obj, const char *signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags))
|
DECL(unsigned long, g_signal_connect_data, (GObject *obj, const char *signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags))
|
||||||
|
|
||||||
// Messages
|
// Messages
|
||||||
|
|||||||
BIN
title_only.png
Normal file
BIN
title_only.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
2
title_only.svg
Normal file
2
title_only.svg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg fill="#000000" width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm0 2 .001 4H4V5h16zM4 19v-8h16.001l.001 8H4z"/><path d="M14 6h2v2h-2zm3 0h2v2h-2z"/></svg>
|
||||||
|
After Width: | Height: | Size: 414 B |
39
tr.cpp
39
tr.cpp
@@ -1,5 +1,6 @@
|
|||||||
#include "tr.h"
|
#include "tr.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
void tr::add(const char *sentence, ...)
|
void tr::add(const char *sentence, ...)
|
||||||
{
|
{
|
||||||
@@ -39,9 +40,12 @@ const char *tr::translate(const char *str)
|
|||||||
{
|
{
|
||||||
std::unordered_map<std::string, Translations_t *>::iterator it;
|
std::unordered_map<std::string, Translations_t *>::iterator it;
|
||||||
|
|
||||||
|
if (_lang == "en") { return str; }
|
||||||
|
|
||||||
it = _translations.find(_lang);
|
it = _translations.find(_lang);
|
||||||
|
|
||||||
if (it == _translations.end()) {
|
if (it == _translations.end()) {
|
||||||
|
std::cerr << "No translation for: " << str << std::endl;
|
||||||
return str;
|
return str;
|
||||||
} else {
|
} else {
|
||||||
Translations_t *m = it->second;
|
Translations_t *m = it->second;
|
||||||
@@ -49,6 +53,7 @@ const char *tr::translate(const char *str)
|
|||||||
std::string s(str);
|
std::string s(str);
|
||||||
n_it = m->find(s);
|
n_it = m->find(s);
|
||||||
if (n_it == m->end()) {
|
if (n_it == m->end()) {
|
||||||
|
std::cerr << "No translation for: " << str << std::endl;
|
||||||
return str;
|
return str;
|
||||||
} else {
|
} else {
|
||||||
return n_it->second.c_str();
|
return n_it->second.c_str();
|
||||||
@@ -61,14 +66,36 @@ void tr::setLang(const std::string &l)
|
|||||||
_lang = l;
|
_lang = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define nl(a, b) add(a, "nl:" b, nullptr)
|
||||||
|
#define en(a, b) add(a, "en:" b, nullptr)
|
||||||
|
|
||||||
tr::tr()
|
tr::tr()
|
||||||
{
|
{
|
||||||
add("Quit", "nl:Beëindigen", nullptr);
|
|
||||||
add("New Note", "nl:Nieuwe Notitie", nullptr);
|
nl("Quit", "Beëindigen");
|
||||||
add("Show Notes", "nl:Notities Presenteren", nullptr);
|
nl("New Note", "Nieuwe Notitie");
|
||||||
add("Hide Notes", "nl:Notities Verbergen", nullptr);
|
nl("Show Notes", "Notities Presenteren");
|
||||||
add("Reload Notes", "nl:Notities opnieuw laden", nullptr);
|
nl("Hide Notes", "Notities Verbergen");
|
||||||
add("Setup", "nl:Instellingen", nullptr);
|
nl("Reload Notes", "Notities opnieuw laden");
|
||||||
|
nl("Setup", "Instellingen");
|
||||||
|
nl("Notes on desktop", "Noties naar achteren");
|
||||||
|
nl("Language:", "Taalinstelling:");
|
||||||
|
nl("Language:", "Taalinstelling:");
|
||||||
|
nl("Ok", "Ok");
|
||||||
|
nl("Yellownotes Setup", "Yellownotes Instellingen");
|
||||||
|
nl("Foreground Color", "Voorgrond kleur");
|
||||||
|
nl("Background Color", "Achtergrond kleur");
|
||||||
|
nl("Dark", "Donker");
|
||||||
|
nl("Yellow", "Geel");
|
||||||
|
nl("Orange", "Oranje");
|
||||||
|
nl("Blue", "Blauw");
|
||||||
|
nl("Cyan", "Cyaan");
|
||||||
|
nl("Green", "Groen");
|
||||||
|
nl("Red", "Rood");
|
||||||
|
nl("Grey", "Grijs");
|
||||||
|
nl("Font size:", "Lettertype Grootte:");
|
||||||
|
nl("Actual Font Size in Note", "Werkelijke lettertype grootte in de notitie");
|
||||||
|
|
||||||
_lang = "en";
|
_lang = "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
192
yellownotes.cpp
192
yellownotes.cpp
@@ -52,6 +52,7 @@ private:
|
|||||||
GtkImage *_plus_image;
|
GtkImage *_plus_image;
|
||||||
GtkImage *_hide_image;
|
GtkImage *_hide_image;
|
||||||
GtkImage *_to_desktop_image;
|
GtkImage *_to_desktop_image;
|
||||||
|
GtkImage *_title_only_image;
|
||||||
GtkWidget *_title_label;
|
GtkWidget *_title_label;
|
||||||
GtkWidget *_title_entry;
|
GtkWidget *_title_entry;
|
||||||
GtkWidget *_title_separator;
|
GtkWidget *_title_separator;
|
||||||
@@ -67,6 +68,9 @@ private:
|
|||||||
bool _hidden;
|
bool _hidden;
|
||||||
bool _hidden_loaded;
|
bool _hidden_loaded;
|
||||||
|
|
||||||
|
bool _title_only;
|
||||||
|
bool _title_only_loaded;
|
||||||
|
|
||||||
int _x;
|
int _x;
|
||||||
int _y;
|
int _y;
|
||||||
bool _pos_loaded;
|
bool _pos_loaded;
|
||||||
@@ -102,6 +106,7 @@ private:
|
|||||||
void updatePosition();
|
void updatePosition();
|
||||||
void updateHidden();
|
void updateHidden();
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
void updateTitleOnly();
|
||||||
|
|
||||||
void adjustTitle(bool mutate);
|
void adjustTitle(bool mutate);
|
||||||
|
|
||||||
@@ -125,6 +130,7 @@ public:
|
|||||||
void toDesktop();
|
void toDesktop();
|
||||||
void fromDesktop();
|
void fromDesktop();
|
||||||
void updateColor();
|
void updateColor();
|
||||||
|
void toggleTitleOnly();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool move_begin(GtkWidget *sender, GdkEventButton *evt);
|
bool move_begin(GtkWidget *sender, GdkEventButton *evt);
|
||||||
@@ -142,6 +148,7 @@ public:
|
|||||||
std::string title();
|
std::string title();
|
||||||
bool isHidden();
|
bool isHidden();
|
||||||
void doubleClicked();
|
void doubleClicked();
|
||||||
|
YellowNotes *notes();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void load();
|
void load();
|
||||||
@@ -152,11 +159,14 @@ public:
|
|||||||
~YellowNote();
|
~YellowNote();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ColorSet
|
class SettingContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorType_t color;
|
ColorType_t color;
|
||||||
|
GtkLabel *font_label;
|
||||||
|
GtkSpinButton *font_size_btn;
|
||||||
YellowNotes *notes;
|
YellowNotes *notes;
|
||||||
|
YellowNote *note;
|
||||||
bool bg;
|
bool bg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -171,14 +181,31 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorSet(ColorType_t t, bool _bg, YellowNotes *n) {
|
void fontSizeSet(GtkWidget *Sender) {
|
||||||
|
int size = gtk_spin_button_get_value_as_int(font_size_btn);
|
||||||
|
notes->updateWidgetCss(font_label, ColorType_t::YELLOW);
|
||||||
|
notes->setFontSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingContainer(ColorType_t t, bool _bg, YellowNotes *n) {
|
||||||
color = t;
|
color = t;
|
||||||
bg = _bg;
|
bg = _bg;
|
||||||
notes = n;
|
notes = n;
|
||||||
|
font_label = nullptr;
|
||||||
|
font_size_btn = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingContainer(GtkSpinButton *btn, GtkLabel *fl, YellowNotes *n) {
|
||||||
|
color = FIRST;
|
||||||
|
font_label = fl;
|
||||||
|
font_size_btn = btn;
|
||||||
|
notes = n;
|
||||||
|
bg = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SIGNAL(ColorSet, on_color_set, colorSet);
|
SIGNAL(SettingContainer, on_color_set, colorSet);
|
||||||
|
SIGNAL(SettingContainer, on_font_size_set, fontSizeSet);
|
||||||
|
|
||||||
SIGNAL2(YellowNote, on_size_allocated, size_allocated, GtkAllocation)
|
SIGNAL2(YellowNote, on_size_allocated, size_allocated, GtkAllocation)
|
||||||
BSIGNAL2(YellowNote, on_button_press, move_begin, GdkEventButton);
|
BSIGNAL2(YellowNote, on_button_press, move_begin, GdkEventButton);
|
||||||
@@ -284,6 +311,20 @@ void YellowNotes::toRGBA(const std::string &col, GdkRGBA &rgba)
|
|||||||
rgba.red = red;
|
rgba.red = red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YellowNotes::updateWidgetCss(GtkWidget *w, ColorType_t col)
|
||||||
|
{
|
||||||
|
auto set_style = [this, col](GtkWidget *widget) {
|
||||||
|
GtkStyleContext *c = gtk_widget_get_style_context(widget);
|
||||||
|
const char *style = gtk_style_context_to_string(c, GTK_STYLE_CONTEXT_PRINT_RECURSE);
|
||||||
|
GtkCssProvider *css_p = gtk_css_provider_new();
|
||||||
|
gtk_style_context_add_provider(c, css_p, GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||||
|
std::string widget_css = css(col);
|
||||||
|
gtk_css_provider_load_from_data(css_p, widget_css.c_str(), widget_css.size(), nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
set_style(w);
|
||||||
|
}
|
||||||
|
|
||||||
std::string YellowNotes::getFgColor(ColorType_t type)
|
std::string YellowNotes::getFgColor(ColorType_t type)
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
@@ -395,9 +436,28 @@ std::string YellowNotes::css(ColorType_t type)
|
|||||||
|
|
||||||
int YellowNotes::fontSize()
|
int YellowNotes::fontSize()
|
||||||
{
|
{
|
||||||
|
std::string key("font_size");
|
||||||
|
std::unordered_map<std::string, std::string>::iterator it;
|
||||||
|
it = _cfg.find(key);
|
||||||
|
if (it != _cfg.end()) {
|
||||||
|
_font_size = atoi(it->second.c_str());
|
||||||
|
if (_font_size < 6 || _font_size > 30) { _font_size = 15; }
|
||||||
|
}
|
||||||
return _font_size;
|
return _font_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YellowNotes::setFontSize(int size)
|
||||||
|
{
|
||||||
|
_font_size = size;
|
||||||
|
char buf[100];
|
||||||
|
sprintf(buf, "%d", size);
|
||||||
|
std::string v = buf;
|
||||||
|
std::string key("font_size");
|
||||||
|
_cfg.erase(key);
|
||||||
|
_cfg.insert(std::pair<std::string, std::string>(key, v));
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
int YellowNotes::iconSize()
|
int YellowNotes::iconSize()
|
||||||
{
|
{
|
||||||
return _font_size * 1.5;
|
return _font_size * 1.5;
|
||||||
@@ -520,7 +580,6 @@ void YellowNotes::loadConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLang(currentLang());
|
setLang(currentLang());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void YellowNotes::saveConfig()
|
void YellowNotes::saveConfig()
|
||||||
@@ -639,12 +698,12 @@ void YellowNotes::setupClose(GtkWidget *sender)
|
|||||||
setCurrentLang(lang);
|
setCurrentLang(lang);
|
||||||
gtk_widget_destroy(_dlg);
|
gtk_widget_destroy(_dlg);
|
||||||
|
|
||||||
std::list<ColorSet *>::iterator it;
|
std::list<SettingContainer *>::iterator it;
|
||||||
for(it = _color_sets.begin() ; it != _color_sets.end(); it++) {
|
for(it = _settings_containers.begin() ; it != _settings_containers.end(); it++) {
|
||||||
ColorSet *s = *it;
|
SettingContainer *s = *it;
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
_color_sets.clear();
|
_settings_containers.clear();
|
||||||
|
|
||||||
_dlg = nullptr;
|
_dlg = nullptr;
|
||||||
_langs = nullptr;
|
_langs = nullptr;
|
||||||
@@ -689,7 +748,7 @@ void YellowNotes::setup(void *sender)
|
|||||||
gtk_grid_attach(grid, lbl_langs, 0, 0, 1, 1);
|
gtk_grid_attach(grid, lbl_langs, 0, 0, 1, 1);
|
||||||
gtk_grid_attach(grid, langs, 1, 0, 2, 1);
|
gtk_grid_attach(grid, langs, 1, 0, 2, 1);
|
||||||
|
|
||||||
GtkLabel *lbl_fg = gtk_label_new(_("Forground Color"));
|
GtkLabel *lbl_fg = gtk_label_new(_("Foreground Color"));
|
||||||
GtkLabel *lbl_bg = gtk_label_new(_("Background Color"));
|
GtkLabel *lbl_bg = gtk_label_new(_("Background Color"));
|
||||||
gtk_grid_attach(grid, lbl_fg, 1, 1, 1, 1);
|
gtk_grid_attach(grid, lbl_fg, 1, 1, 1, 1);
|
||||||
gtk_grid_attach(grid, lbl_bg, 2, 1, 1, 1);
|
gtk_grid_attach(grid, lbl_bg, 2, 1, 1, 1);
|
||||||
@@ -713,18 +772,35 @@ void YellowNotes::setup(void *sender)
|
|||||||
|
|
||||||
GtkColorButton *fg_btn = gtk_color_button_new();
|
GtkColorButton *fg_btn = gtk_color_button_new();
|
||||||
gtk_color_chooser_set_rgba(fg_btn, &fg_rgba);
|
gtk_color_chooser_set_rgba(fg_btn, &fg_rgba);
|
||||||
ColorSet *fg = new ColorSet(static_cast<ColorType_t>(i), false, this);
|
SettingContainer *fg = new SettingContainer(static_cast<ColorType_t>(i), false, this);
|
||||||
|
_settings_containers.push_back(fg);
|
||||||
g_signal_connect(fg_btn, "color_set", on_color_set, fg);
|
g_signal_connect(fg_btn, "color_set", on_color_set, fg);
|
||||||
gtk_grid_attach(grid, fg_btn, 1, i + offset, 1, 1);
|
gtk_grid_attach(grid, fg_btn, 1, i + offset, 1, 1);
|
||||||
|
|
||||||
GtkColorButton *bg_btn = gtk_color_button_new();
|
GtkColorButton *bg_btn = gtk_color_button_new();
|
||||||
gtk_color_chooser_set_rgba(bg_btn, &bg_rgba);
|
gtk_color_chooser_set_rgba(bg_btn, &bg_rgba);
|
||||||
ColorSet *bg = new ColorSet(static_cast<ColorType_t>(i), true, this);
|
SettingContainer *bg = new SettingContainer(static_cast<ColorType_t>(i), true, this);
|
||||||
|
_settings_containers.push_back(bg);
|
||||||
g_signal_connect(bg_btn, "color_set", on_color_set, bg);
|
g_signal_connect(bg_btn, "color_set", on_color_set, bg);
|
||||||
gtk_grid_attach(grid, bg_btn, 2, i + offset, 1, 1);
|
gtk_grid_attach(grid, bg_btn, 2, i + offset, 1, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset = i + offset;
|
||||||
|
|
||||||
|
gtk_grid_attach(grid, gtk_label_new(_("Font size:")), 0, offset, 1, 1);
|
||||||
|
GtkSpinButton *fs = gtk_spin_button_new_with_range(6.0, 20.0, 1.0);
|
||||||
|
gtk_spin_button_set_value(fs, fontSize());
|
||||||
|
gtk_grid_attach(grid, fs, 1, offset, 1, 1);
|
||||||
|
|
||||||
|
GtkLabel *font_label = gtk_label_new(_("Actual Font Size in Note"));
|
||||||
|
gtk_widget_set_size_request(font_label, 400, -1);
|
||||||
|
gtk_grid_attach(grid, font_label, 2, offset, 1, 1);
|
||||||
|
|
||||||
|
SettingContainer *fl = new SettingContainer(fs, font_label, this);
|
||||||
|
_settings_containers.push_back(fl);
|
||||||
|
g_signal_connect(fs, "value_changed", on_font_size_set, fl);
|
||||||
|
fl->fontSizeSet(fs);
|
||||||
|
|
||||||
gtk_container_add(content, grid);
|
gtk_container_add(content, grid);
|
||||||
|
|
||||||
g_signal_connect(ok_btn, "clicked", on_setup_ok, this);
|
g_signal_connect(ok_btn, "clicked", on_setup_ok, this);
|
||||||
@@ -874,6 +950,7 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
|
|||||||
_width = 300;
|
_width = 300;
|
||||||
_height = 200;
|
_height = 200;
|
||||||
_hidden = false;
|
_hidden = false;
|
||||||
|
_title_only = false;
|
||||||
_editing_title = false;
|
_editing_title = false;
|
||||||
_save_counter = 0;
|
_save_counter = 0;
|
||||||
_save_id = -1;
|
_save_id = -1;
|
||||||
@@ -965,12 +1042,21 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
|
|||||||
gtk_widget_set_halign(_to_desktop_image, GtkAlign::GTK_ALIGN_END);
|
gtk_widget_set_halign(_to_desktop_image, GtkAlign::GTK_ALIGN_END);
|
||||||
g_object_unref(to_desktop_pixbuf);
|
g_object_unref(to_desktop_pixbuf);
|
||||||
|
|
||||||
|
GdkPixbuf *title_only_pixbuf = gdk_pixbuf_new_from_file_at_size(notes->imageFile("title_only").c_str(),
|
||||||
|
width, height, nullptr
|
||||||
|
);
|
||||||
|
_title_only_image = gtk_image_new_from_pixbuf(title_only_pixbuf);
|
||||||
|
gtk_widget_set_halign(_title_only_image, GtkAlign::GTK_ALIGN_END);
|
||||||
|
g_object_unref(title_only_pixbuf);
|
||||||
|
|
||||||
|
|
||||||
gtk_container_add(_note_header, _color_image);
|
gtk_container_add(_note_header, _color_image);
|
||||||
gtk_container_add(_note_header, _title_label);
|
gtk_container_add(_note_header, _title_label);
|
||||||
gtk_container_add(_note_header, _plus_image);
|
gtk_container_add(_note_header, _plus_image);
|
||||||
gtk_container_add(_note_header, _delete_image);
|
gtk_container_add(_note_header, _delete_image);
|
||||||
gtk_container_add(_note_header, _hide_image);
|
gtk_container_add(_note_header, _hide_image);
|
||||||
gtk_container_add(_note_header, _to_desktop_image);
|
gtk_container_add(_note_header, _to_desktop_image);
|
||||||
|
gtk_container_add(_note_header, _title_only_image);
|
||||||
|
|
||||||
gtk_container_add(_scroll_widget, _text_widget);
|
gtk_container_add(_scroll_widget, _text_widget);
|
||||||
|
|
||||||
@@ -1013,6 +1099,7 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
|
|||||||
g_object_ref(_plus_image);
|
g_object_ref(_plus_image);
|
||||||
g_object_ref(_hide_image);
|
g_object_ref(_hide_image);
|
||||||
g_object_ref(_to_desktop_image);
|
g_object_ref(_to_desktop_image);
|
||||||
|
g_object_ref(_title_only_image);
|
||||||
|
|
||||||
load();
|
load();
|
||||||
|
|
||||||
@@ -1027,6 +1114,7 @@ YellowNote::~YellowNote()
|
|||||||
g_object_unref(_plus_image);
|
g_object_unref(_plus_image);
|
||||||
g_object_unref(_hide_image);
|
g_object_unref(_hide_image);
|
||||||
g_object_unref(_to_desktop_image);
|
g_object_unref(_to_desktop_image);
|
||||||
|
g_object_unref(_title_only_image);
|
||||||
gtk_widget_destroy(_note_widget);
|
gtk_widget_destroy(_note_widget);
|
||||||
_note_widget = nullptr;
|
_note_widget = nullptr;
|
||||||
}
|
}
|
||||||
@@ -1043,6 +1131,7 @@ void YellowNote::updateWidgetColors(GtkWidget *w)
|
|||||||
};
|
};
|
||||||
|
|
||||||
set_style(w);
|
set_style(w);
|
||||||
|
_notes->updateWidgetCss(w, _color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YellowNote::updateColor()
|
void YellowNote::updateColor()
|
||||||
@@ -1102,6 +1191,19 @@ void YellowNote::updateTitle()
|
|||||||
gtk_label_set_label(_title_label, _title.c_str());
|
gtk_label_set_label(_title_label, _title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YellowNote::updateTitleOnly()
|
||||||
|
{
|
||||||
|
if (_title_only) {
|
||||||
|
gtk_widget_hide(_scroll_widget);
|
||||||
|
GtkAllocation alloc;
|
||||||
|
gtk_widget_get_allocation(_note_header, &alloc);
|
||||||
|
gtk_window_resize(_note_widget, _width, alloc.height);
|
||||||
|
} else {
|
||||||
|
gtk_widget_show_all(_scroll_widget);
|
||||||
|
gtk_window_resize(_note_widget, _width, _height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void YellowNote::updateHidden()
|
void YellowNote::updateHidden()
|
||||||
{
|
{
|
||||||
if (_hidden) { hide(); }
|
if (_hidden) { hide(); }
|
||||||
@@ -1115,8 +1217,8 @@ void YellowNote::updatePosition()
|
|||||||
|
|
||||||
void YellowNote::updateSize()
|
void YellowNote::updateSize()
|
||||||
{
|
{
|
||||||
std::cout << "Update size to: " << _width << ", " << _height << std::endl;
|
updateTitleOnly();
|
||||||
gtk_window_resize(_note_widget, _width, _height);
|
//gtk_window_resize(_note_widget, _width, _height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YellowNote::showNote(GtkWidget *sender)
|
void YellowNote::showNote(GtkWidget *sender)
|
||||||
@@ -1138,6 +1240,12 @@ void YellowNote::hide()
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YellowNote::toggleTitleOnly()
|
||||||
|
{
|
||||||
|
_title_only = !_title_only;
|
||||||
|
updateTitleOnly();
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
void YellowNote::resized(int width, int height)
|
void YellowNote::resized(int width, int height)
|
||||||
{
|
{
|
||||||
@@ -1148,18 +1256,12 @@ void YellowNote::resized(int width, int height)
|
|||||||
|
|
||||||
void YellowNote::size_allocated(GtkWidget *sender, GtkAllocation *alloc)
|
void YellowNote::size_allocated(GtkWidget *sender, GtkAllocation *alloc)
|
||||||
{
|
{
|
||||||
std::cout << "loaded: " << _size_loaded << ", " << _pos_loaded << std::endl;
|
|
||||||
int width = alloc->width;
|
int width = alloc->width;
|
||||||
int height = alloc->height;
|
int height = alloc->height;
|
||||||
//if (_size_loaded) {
|
|
||||||
std::cout << "width, height = " << width << ", " << height << std::endl;
|
|
||||||
// _width = width;
|
|
||||||
// _height = height;
|
|
||||||
// save();
|
|
||||||
// }
|
|
||||||
if (!_moving) {
|
if (!_moving) {
|
||||||
if (width != _width || height != _height) {
|
if (width != _width || height != _height) {
|
||||||
gtk_window_resize(_note_widget, _width, _height);
|
updateSize();
|
||||||
|
//gtk_window_resize(_note_widget, _width, _height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1179,7 +1281,6 @@ void YellowNote::toFront()
|
|||||||
gtk_window_move(_note_widget, _x, _y);
|
gtk_window_move(_note_widget, _x, _y);
|
||||||
gtk_widget_hide(_note_widget);
|
gtk_widget_hide(_note_widget);
|
||||||
} else {
|
} else {
|
||||||
std::cout << "to_front x = " << _x << std::endl;
|
|
||||||
int x = _x;
|
int x = _x;
|
||||||
int y = _y;
|
int y = _y;
|
||||||
gtk_window_present(_note_widget);
|
gtk_window_present(_note_widget);
|
||||||
@@ -1191,7 +1292,6 @@ void YellowNote::toFront()
|
|||||||
void YellowNote::toDesktop()
|
void YellowNote::toDesktop()
|
||||||
{
|
{
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
std::cout << "todesktop: width: " << _width << ", height: " << _height << std::endl;
|
|
||||||
gtk_window_set_type_hint(_note_widget, GdkWindowTypeHint::GDK_WINDOW_TYPE_HINT_DESKTOP);
|
gtk_window_set_type_hint(_note_widget, GdkWindowTypeHint::GDK_WINDOW_TYPE_HINT_DESKTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1260,6 +1360,8 @@ void YellowNote::adjustTitle(bool mutate)
|
|||||||
gtk_container_add(_note_header, _hide_image);
|
gtk_container_add(_note_header, _hide_image);
|
||||||
gtk_container_remove(_note_header, _to_desktop_image);
|
gtk_container_remove(_note_header, _to_desktop_image);
|
||||||
gtk_container_add(_note_header, _to_desktop_image);
|
gtk_container_add(_note_header, _to_desktop_image);
|
||||||
|
gtk_container_remove(_note_header, _title_only_image);
|
||||||
|
gtk_container_add(_note_header, _title_only_image);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1342,6 +1444,11 @@ void YellowNote::doubleClicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YellowNotes *YellowNote::notes()
|
||||||
|
{
|
||||||
|
return _notes;
|
||||||
|
}
|
||||||
|
|
||||||
bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
||||||
{
|
{
|
||||||
int x = evt->x_root;
|
int x = evt->x_root;
|
||||||
@@ -1368,6 +1475,9 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
|||||||
int to_desktop_left, to_desktop_right;
|
int to_desktop_left, to_desktop_right;
|
||||||
get_screen_left_right(_to_desktop_image, to_desktop_left, to_desktop_right);
|
get_screen_left_right(_to_desktop_image, to_desktop_left, to_desktop_right);
|
||||||
|
|
||||||
|
int title_only_left, title_only_right;
|
||||||
|
get_screen_left_right(_title_only_image, title_only_left, title_only_right);
|
||||||
|
|
||||||
if (y >= header_top && y <= header_bottom) {
|
if (y >= header_top && y <= header_bottom) {
|
||||||
if (x >= color_left && x <= color_right) {
|
if (x >= color_left && x <= color_right) {
|
||||||
nextColor();
|
nextColor();
|
||||||
@@ -1385,6 +1495,10 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
|||||||
_notes->notesToDesktop(this);
|
_notes->notesToDesktop(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (x >= title_only_left && x <= title_only_right) {
|
||||||
|
toggleTitleOnly();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (x >= delete_left && x <= delete_right) {
|
if (x >= delete_left && x <= delete_right) {
|
||||||
deleteMe();
|
deleteMe();
|
||||||
return true;
|
return true;
|
||||||
@@ -1402,6 +1516,8 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
|||||||
gtk_container_add(_note_header, _hide_image);
|
gtk_container_add(_note_header, _hide_image);
|
||||||
gtk_container_remove(_note_header, _to_desktop_image);
|
gtk_container_remove(_note_header, _to_desktop_image);
|
||||||
gtk_container_add(_note_header, _to_desktop_image);
|
gtk_container_add(_note_header, _to_desktop_image);
|
||||||
|
gtk_container_remove(_note_header, _title_only_image);
|
||||||
|
gtk_container_add(_note_header, _title_only_image);
|
||||||
gtk_widget_show(_title_entry);
|
gtk_widget_show(_title_entry);
|
||||||
gtk_entry_set_text(_title_entry, _title.c_str());
|
gtk_entry_set_text(_title_entry, _title.c_str());
|
||||||
gtk_widget_grab_focus(_title_entry);
|
gtk_widget_grab_focus(_title_entry);
|
||||||
@@ -1456,7 +1572,6 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
|||||||
if (_moving) {
|
if (_moving) {
|
||||||
int the_x = x - _x_orig;
|
int the_x = x - _x_orig;
|
||||||
int the_y = y - _y_orig;
|
int the_y = y - _y_orig;
|
||||||
std::cout << "moving" << std::endl;
|
|
||||||
gtk_window_move(_note_widget, the_x, the_y);
|
gtk_window_move(_note_widget, the_x, the_y);
|
||||||
positioned(_note_widget, the_x, the_y);
|
positioned(_note_widget, the_x, the_y);
|
||||||
return true;
|
return true;
|
||||||
@@ -1472,8 +1587,6 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
|||||||
if (height < 60) { height = 60; }
|
if (height < 60) { height = 60; }
|
||||||
gtk_window_resize(_note_widget, width, height);
|
gtk_window_resize(_note_widget, width, height);
|
||||||
resized(width, height);
|
resized(width, height);
|
||||||
|
|
||||||
//size_allocated(_note_box, width, height);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1486,7 +1599,6 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
|||||||
if (width < 100) { width = 100; }
|
if (width < 100) { width = 100; }
|
||||||
gtk_window_resize(_note_widget, width, h);
|
gtk_window_resize(_note_widget, width, h);
|
||||||
resized(width, h);
|
resized(width, h);
|
||||||
//size_allocated(_note_box, width, h);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1499,7 +1611,6 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
|||||||
if (height < 60) { height = 60; }
|
if (height < 60) { height = 60; }
|
||||||
gtk_window_resize(_note_widget, w, height);
|
gtk_window_resize(_note_widget, w, height);
|
||||||
resized(w, height);
|
resized(w, height);
|
||||||
//size_allocated(_note_box, w, height);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1533,7 +1644,7 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YELLOWNOTE_VERSION 1
|
#define YELLOWNOTE_VERSION 2
|
||||||
|
|
||||||
void YellowNote::load()
|
void YellowNote::load()
|
||||||
{
|
{
|
||||||
@@ -1554,6 +1665,7 @@ void YellowNote::load()
|
|||||||
int hidden, x, y, width, height;
|
int hidden, x, y, width, height;
|
||||||
ColorType_t c;
|
ColorType_t c;
|
||||||
std::string title;
|
std::string title;
|
||||||
|
bool title_only;
|
||||||
|
|
||||||
size_t s = 0;
|
size_t s = 0;
|
||||||
if (std::filesystem::is_regular_file(p)) {
|
if (std::filesystem::is_regular_file(p)) {
|
||||||
@@ -1574,6 +1686,11 @@ void YellowNote::load()
|
|||||||
color = readInt(f, ColorType_t::YELLOW);
|
color = readInt(f, ColorType_t::YELLOW);
|
||||||
c = static_cast<ColorType_t>(color);
|
c = static_cast<ColorType_t>(color);
|
||||||
|
|
||||||
|
if (version >= 2) {
|
||||||
|
int t = readInt(f, 0);
|
||||||
|
title_only = (t) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
char *buf = static_cast<char *>(malloc(s));
|
char *buf = static_cast<char *>(malloc(s));
|
||||||
memset(buf, 0, s);
|
memset(buf, 0, s);
|
||||||
|
|
||||||
@@ -1600,13 +1717,17 @@ void YellowNote::load()
|
|||||||
_pos_loaded = true;
|
_pos_loaded = true;
|
||||||
updatePosition();
|
updatePosition();
|
||||||
|
|
||||||
_width = width; _height = height;
|
|
||||||
_size_loaded = true;
|
|
||||||
updateSize();
|
|
||||||
|
|
||||||
_hidden = hidden;
|
_hidden = hidden;
|
||||||
_hidden_loaded = true;
|
_hidden_loaded = true;
|
||||||
updateHidden();
|
updateHidden();
|
||||||
|
|
||||||
|
_title_only = title_only;
|
||||||
|
_title_only_loaded = true;
|
||||||
|
updateTitleOnly();
|
||||||
|
|
||||||
|
_width = width; _height = height;
|
||||||
|
_size_loaded = true;
|
||||||
|
updateSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1619,8 +1740,6 @@ void YellowNote::save()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Saving " << _title << "..." << _size_loaded << ", " << _width << ", h = " << _height << std::endl;
|
|
||||||
|
|
||||||
std::filesystem::path p(_filename);
|
std::filesystem::path p(_filename);
|
||||||
FILE *f = fopen(_filename.c_str(), "wt");
|
FILE *f = fopen(_filename.c_str(), "wt");
|
||||||
if (f) {
|
if (f) {
|
||||||
@@ -1631,6 +1750,7 @@ void YellowNote::save()
|
|||||||
fprintf(f, "%d\n", _width);
|
fprintf(f, "%d\n", _width);
|
||||||
fprintf(f, "%d\n", _height);
|
fprintf(f, "%d\n", _height);
|
||||||
fprintf(f, "%d\n", _color);
|
fprintf(f, "%d\n", _color);
|
||||||
|
fprintf(f, "%d\n", _title_only);
|
||||||
fprintf(f, "%s\n", _title.c_str());
|
fprintf(f, "%s\n", _title.c_str());
|
||||||
|
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YellowNote;
|
class YellowNote;
|
||||||
class ColorSet;
|
class SettingContainer;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DARK = 0,
|
DARK = 0,
|
||||||
@@ -33,7 +33,7 @@ private:
|
|||||||
void *_dlg;
|
void *_dlg;
|
||||||
void *_langs;
|
void *_langs;
|
||||||
|
|
||||||
std::list<ColorSet *> _color_sets;
|
std::list<SettingContainer *> _settings_containers;
|
||||||
|
|
||||||
std::list<YellowNote *> _notes;
|
std::list<YellowNote *> _notes;
|
||||||
int _font_size;
|
int _font_size;
|
||||||
@@ -56,6 +56,8 @@ public:
|
|||||||
int fontSize();
|
int fontSize();
|
||||||
int iconSize();
|
int iconSize();
|
||||||
GtkWindow *topLevel();
|
GtkWindow *topLevel();
|
||||||
|
void colorSet(void *sender);
|
||||||
|
void setFontSize(int size);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void popupTrayMenu(void *sender);
|
void popupTrayMenu(void *sender);
|
||||||
@@ -83,11 +85,11 @@ public:
|
|||||||
void setBgColor(ColorType_t type, const std::string &col);
|
void setBgColor(ColorType_t type, const std::string &col);
|
||||||
std::string fromRGBA(const GdkRGBA &rgba);
|
std::string fromRGBA(const GdkRGBA &rgba);
|
||||||
void toRGBA(const std::string &col, GdkRGBA &rgba);
|
void toRGBA(const std::string &col, GdkRGBA &rgba);
|
||||||
|
void updateWidgetCss(GtkWidget *w, ColorType_t col);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
YellowNotes(void *app);
|
YellowNotes(void *app);
|
||||||
~YellowNotes();
|
~YellowNotes();
|
||||||
void colorSet(void *sender);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define YELLOWNOTES(obj) reinterpret_cast<YellowNotes *>(obj)
|
#define YELLOWNOTES(obj) reinterpret_cast<YellowNotes *>(obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user