Changeset 732c22f27b65ef45c0c1b5142b735804990451ec
- Timestamp:
- 11/09/09 16:36:58 (4 years ago)
- Author:
- Benjamin Herr <ben@…>
- git-author:
- Benjamin Herr <ben@0x539.de> / 2009-11-09T14:24:00Z+0100
- Parents:
- 74e640926423470402269ebe48f3082b89e6cba9
- Children:
- 2a1e37c2ebaa4d166360a8bed2b730ac8cdc8203
- git-committer:
- Benjamin Herr <ben@0x539.de> / 2009-11-09T16:36:58Z+0100
- Message:
-
minor refactoring to status bar message change
2009-11-09 Benjamin Herr <ben@…>
- code/core/statusbar.cpp:
- code/core/statusbar.hpp: Minor refactoring to below's minor
refactoring. Made more stuff a detail of StatusBar::Message.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r74e6409
|
r732c22f
|
|
| | 1 | 2009-11-09 Benjamin Herr <ben@0x539.de> |
| | 2 | |
| | 3 | * code/core/statusbar.cpp: |
| | 4 | * code/core/statusbar.hpp: Minor refactoring to the status bar message |
| | 5 | change. Also made more stuff a detail of StatusBar::Message. |
| | 6 | |
| 1 | 7 | 2009-11-08 Armin Burgmeier <armin@arbur.net> |
| 2 | 8 | |
-
|
r646a4f3
|
r732c22f
|
|
| 34 | 34 | case Gobby::StatusBar::ERROR: |
| 35 | 35 | return Gtk::Stock::DIALOG_ERROR; |
| 36 | | default: |
| | 36 | default: |
| 37 | 37 | g_assert_not_reached(); |
| 38 | 38 | } |
| … |
… |
|
| 43 | 43 | { |
| 44 | 44 | public: |
| 45 | | Message(Gtk::Widget* widget): |
| 46 | | m_widget(widget) {} |
| 47 | | ~Message() { m_conn.disconnect(); } |
| 48 | | |
| 49 | | void set_timeout_connection(sigc::connection timeout_conn) |
| 50 | | { |
| 51 | | m_conn = timeout_conn; |
| | 45 | Message(Gtk::Widget* widget, |
| | 46 | const Glib::ustring& simple, |
| | 47 | const Glib::ustring& detail): |
| | 48 | m_widget(widget), m_simple_desc(simple), m_detail_desc(detail) |
| | 49 | { |
| | 50 | } |
| | 51 | |
| | 52 | void show_dialog() const |
| | 53 | { |
| | 54 | Gtk::MessageDialog dialog( |
| | 55 | m_simple_desc, |
| | 56 | false, |
| | 57 | Gtk::MESSAGE_ERROR, |
| | 58 | Gtk::BUTTONS_OK, |
| | 59 | false); |
| | 60 | |
| | 61 | dialog.set_secondary_text(m_detail_desc, true); |
| | 62 | dialog.run(); |
| 52 | 63 | } |
| 53 | 64 | |
| 54 | 65 | Gtk::Widget* widget() const { return m_widget; } |
| 55 | | |
| | 66 | |
| | 67 | protected: |
| | 68 | Gtk::Widget* m_widget; |
| 56 | 69 | Glib::ustring m_simple_desc; |
| 57 | 70 | Glib::ustring m_detail_desc; |
| 58 | | protected: |
| 59 | | Gtk::Widget* m_widget; |
| 60 | | sigc::connection m_conn; |
| 61 | 71 | }; |
| 62 | 72 | |
| … |
… |
|
| 88 | 98 | |
| 89 | 99 | Gobby::StatusBar::MessageHandle |
| 90 | | Gobby::StatusBar::add_message(MessageType type, |
| | 100 | Gobby::StatusBar::add_message(Gobby::StatusBar::MessageType type, |
| 91 | 101 | const Glib::ustring& message, |
| 92 | 102 | const Glib::ustring& dialog_message) |
| 93 | 103 | { |
| 94 | | if (m_list.size() >= 12) |
| | 104 | if(m_list.size() >= 12) |
| 95 | 105 | Gobby::StatusBar::remove_message(m_list.begin()); |
| 96 | 106 | |
| … |
… |
|
| 112 | 122 | "shadow-type", &shadow_type, NULL); |
| 113 | 123 | Gtk::Frame* frame = Gtk::manage(new Gtk::Frame); |
| 114 | | Gtk::EventBox *eventbox = Gtk::manage(new Gtk::EventBox); |
| 115 | | |
| 116 | | frame->set_shadow_type(static_cast<Gtk::ShadowType>(shadow_type)); |
| 117 | | frame->add(*eventbox); |
| 118 | | eventbox->add(*bar); |
| 119 | | bar->show(); |
| 120 | | |
| 121 | | pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); |
| 122 | | reorder_child(*frame, 0); |
| 123 | | |
| 124 | | m_list.push_back(new Message(frame)); |
| | 124 | |
| | 125 | m_list.push_back(new Message(frame, message, dialog_message)); |
| 125 | 126 | Gobby::StatusBar::MessageHandle iter(--m_list.end()); |
| 126 | | (*iter)->m_simple_desc = message; |
| 127 | | (*iter)->m_detail_desc = dialog_message; |
| 128 | | |
| 129 | | eventbox->signal_button_press_event().connect( |
| 130 | | sigc::bind_return( |
| 131 | | sigc::bind( |
| | 127 | |
| | 128 | if(dialog_message.empty()) |
| | 129 | { |
| | 130 | frame->add(*bar); |
| | 131 | } |
| | 132 | else |
| | 133 | { |
| | 134 | Gtk::EventBox *eventbox = Gtk::manage(new Gtk::EventBox); |
| | 135 | frame->add(*eventbox); |
| | 136 | eventbox->add(*bar); |
| | 137 | eventbox->signal_button_press_event().connect( |
| | 138 | sigc::bind_return(sigc::bind( |
| 132 | 139 | sigc::mem_fun( |
| 133 | 140 | *this, |
| 134 | 141 | &StatusBar::on_message_clicked), |
| 135 | | iter), |
| 136 | | false)); |
| 137 | | |
| 138 | | eventbox->show(); |
| | 142 | iter), false)); |
| | 143 | |
| | 144 | eventbox->show(); |
| | 145 | } |
| | 146 | |
| | 147 | frame->set_shadow_type(static_cast<Gtk::ShadowType>(shadow_type)); |
| | 148 | bar->show(); |
| | 149 | |
| | 150 | pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); |
| | 151 | reorder_child(*frame, 0); |
| | 152 | |
| 139 | 153 | frame->show(); |
| 140 | 154 | |
| … |
… |
|
| 168 | 182 | |
| 169 | 183 | void Gobby::StatusBar::on_message_clicked(GdkEventButton* button, |
| 170 | | const MessageHandle& handler) |
| 171 | | { |
| 172 | | const Glib::ustring& simple = (*handler)->m_simple_desc; |
| 173 | | const Glib::ustring& detail = (*handler)->m_detail_desc; |
| 174 | | |
| 175 | | if(!detail.empty()) |
| 176 | | { |
| 177 | | if (button->button == 1) |
| 178 | | { |
| 179 | | Gtk::MessageDialog *dialog = new Gtk::MessageDialog( |
| 180 | | simple, |
| 181 | | false, |
| 182 | | Gtk::MESSAGE_ERROR, |
| 183 | | Gtk::BUTTONS_CLOSE, |
| 184 | | false |
| 185 | | ); |
| 186 | | |
| 187 | | dialog->set_secondary_text(detail, false); |
| 188 | | dialog->run(); |
| 189 | | |
| 190 | | delete dialog; |
| 191 | | } |
| 192 | | |
| 193 | | remove_message(handler); |
| 194 | | } |
| | 184 | const MessageHandle& handle) |
| | 185 | { |
| | 186 | if(button->button == 1) |
| | 187 | (*handle)->show_dialog(); |
| | 188 | |
| | 189 | remove_message(handle); |
| 195 | 190 | } |
| 196 | 191 | |
-
|
r646a4f3
|
r732c22f
|
|
| 85 | 85 | |
| 86 | 86 | void on_message_clicked(GdkEventButton* button, |
| 87 | | const MessageHandle& message); |
| | 87 | const MessageHandle& handle); |
| 88 | 88 | |
| 89 | 89 | void on_document_removed(SessionView& view); |
| 90 | 90 | void on_document_changed(SessionView* view); |
| 91 | 91 | void on_view_changed(); |
| 92 | | |
| | 92 | |
| 93 | 93 | void on_mark_set(GtkTextMark* mark); |
| 94 | 94 | void on_changed(); |