1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/* Gobby - GTK-based collaborative text editor
* Copyright (C) 2008-2014 Armin Burgmeier <armin@arbur.net>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _GOBBY_TEXTTABLABEL_HPP_
#define _GOBBY_TEXTTABLABEL_HPP_
#include "core/textsessionview.hpp"
#include "core/tablabel.hpp"
namespace Gobby
{
class TextTabLabel: public TabLabel
{
public:
TextTabLabel(Folder& folder, TextSessionView& view);
~TextTabLabel();
protected:
static void on_modified_changed_static(GtkTextBuffer* buffer,
gpointer user_data)
{
static_cast<TextTabLabel*>(user_data)->on_modified_changed();
}
static void on_text_erased_static(InfTextBuffer* buffer,
guint position,
InfTextChunk* chunk,
InfTextUser* author,
gpointer user_data)
{
static_cast<TextTabLabel*>(user_data)->on_changed(author);
}
static void on_text_inserted_static(InfTextBuffer* buffer,
guint position,
InfTextChunk* text,
InfTextUser* author,
gpointer user_data)
{
static_cast<TextTabLabel*>(user_data)->on_changed(author);
}
virtual void on_style_updated();
virtual void on_notify_status(); // override
virtual void on_activate();
void on_modified_changed();
void on_changed(InfTextUser* author);
Gtk::Label m_dots;
private:
void update_modified();
void update_dot_char();
void update_dots();
gunichar m_dot_char;
gulong m_modified_changed_handle;
gulong m_erase_text_handle;
gulong m_insert_text_handle;
class UserWatcher
{
public:
UserWatcher(TextTabLabel* label, InfTextUser* user);
UserWatcher(const UserWatcher& other);
~UserWatcher();
InfTextUser* get_user() const;
bool operator==(InfTextUser* other_user) const;
private:
void connect();
void disconnect();
static void on_notify_hue(GObject* user_object,
GParamSpec* spec,
gpointer user_data);
TabLabel* m_label;
InfTextUser* m_user;
gulong m_handle;
};
typedef std::list<UserWatcher> UserWatcherList;
UserWatcherList m_changed_by;
};
}
#endif // _GOBBY_TEXTTABLABEL_HPP_
|