Browse Source

fixed popup bug and merged with master

master
oyvang 11 years ago
parent
commit
1ccca62ebe
  1. 23
      juci/notebook.cc
  2. 6
      juci/notebook.h
  3. 10
      juci/window.cc
  4. 1
      juci/window.h

23
juci/notebook.cc

@ -13,11 +13,12 @@ Notebook::View::View() {
view_.set_position(120); view_.set_position(120);
} }
Notebook::Controller::Controller(Keybindings::Controller& keybindings, Notebook::Controller::Controller(Gtk::Window& window, Keybindings::Controller& keybindings,
Source::Config& source_cfg, Source::Config& source_cfg,
Directories::Config& dir_cfg) : Directories::Config& dir_cfg) :
source_config_(source_cfg), source_config_(source_cfg),
directories_(dir_cfg) { directories_(dir_cfg) {
window_ = &window;
OnNewPage("juCi++"); OnNewPage("juCi++");
refClipboard_ = Gtk::Clipboard::get(); refClipboard_ = Gtk::Clipboard::get();
ispopup = false; ispopup = false;
@ -138,13 +139,21 @@ bool Notebook::Controller:: OnMouseRelease(GdkEventButton* button){
return false; return false;
} }
bool Notebook::Controller::GeneratePopup(Gtk::Window* window){ bool Notebook::Controller::OnKeyRelease(GdkEventKey* key){
if(key->keyval==46){
return GeneratePopup();
}
return false;
}
bool Notebook::Controller::GeneratePopup(){
// Get function to fill popup with suggests item vector under is for testing // Get function to fill popup with suggests item vector under is for testing
std::vector<std::string> items; std::vector<std::string> items;
Gtk::TextIter start = CurrentTextView().get_buffer()->get_insert()->get_iter(); Gtk::TextIter start = CurrentTextView().get_buffer()->get_insert()->get_iter();
text_vec_.at(CurrentPage())->GetAutoCompleteSuggestions(start.get_line()+1, text_vec_.at(CurrentPage())->GetAutoCompleteSuggestions(start.get_line()+1,
start.get_line_offset()+2, start.get_line_offset()+2,
&items); &items);
std::cout << items.size()<< std::endl;
// Replace over with get suggestions from zalox! OVER IS JUST FOR TESTING // Replace over with get suggestions from zalox! OVER IS JUST FOR TESTING
@ -160,7 +169,7 @@ bool Notebook::Controller::GeneratePopup(Gtk::Window* window){
for (auto &i : items) listview_.append(i); for (auto &i : items) listview_.append(i);
popup_scroll_.add(listview_); popup_scroll_.add(listview_);
popup_.get_vbox()->pack_start(popup_scroll_); popup_.get_vbox()->pack_start(popup_scroll_);
popup_.set_transient_for(*window); popup_.set_transient_for(*window_);
popup_.show_all(); popup_.show_all();
int popup_x = popup_.get_width(); int popup_x = popup_.get_width();
@ -428,6 +437,11 @@ void Notebook::Controller::TextViewHandlers(Gtk::TextView& textview) {
textview.signal_button_release_event(). textview.signal_button_release_event().
connect(sigc::mem_fun(*this,&Notebook::Controller::OnMouseRelease),false); connect(sigc::mem_fun(*this,&Notebook::Controller::OnMouseRelease),false);
textview.signal_key_release_event().
connect(sigc::mem_fun(*this,&Notebook::Controller::OnKeyRelease),false);
} }
void Notebook::Controller::PopupSelectHandler(Gtk::Dialog &popup, void Notebook::Controller::PopupSelectHandler(Gtk::Dialog &popup,
Gtk::ListViewText &listview){ Gtk::ListViewText &listview){
@ -447,6 +461,7 @@ void Notebook::Controller::PopupSetSize(Gtk::ScrolledWindow &scroll,
int textview_y = 150; int textview_y = 150;
bool is_never_scroll_x = true; bool is_never_scroll_x = true;
bool is_never_scroll_y = true; bool is_never_scroll_y = true;
std::cout << textview_x << std::endl;
if (current_x > textview_x) { if (current_x > textview_x) {
current_x = textview_x; current_x = textview_x;
is_never_scroll_x = false; is_never_scroll_x = false;
@ -493,9 +508,11 @@ void Notebook::Controller::FindPopupPosition(Gtk::TextView& textview,
y+=textview_edge_y; y+=textview_edge_y;
if ((textview_edge_x-x)*-1 > textview.get_width()-popup_x) { if ((textview_edge_x-x)*-1 > textview.get_width()-popup_x) {
x -= popup_x; x -= popup_x;
if(x<textview_edge_x) x = textview_edge_x;
} }
if ((textview_edge_y-y)*-1 > textview.get_height()-popup_y) { if ((textview_edge_y-y)*-1 > textview.get_height()-popup_y) {
y -= (popup_y+14) + 15; y -= (popup_y+14) + 15;
if(x<textview_edge_y) y = textview_edge_y +15;
} }
} }

6
juci/notebook.h

@ -29,7 +29,7 @@ namespace Notebook {
}; };
class Controller { class Controller {
public: public:
Controller(Keybindings::Controller& keybindings, Controller(Gtk::Window& window, Keybindings::Controller& keybindings,
Source::Config& config, Source::Config& config,
Directories::Config& dir_cfg); Directories::Config& dir_cfg);
~Controller(); ~Controller();
@ -59,10 +59,11 @@ namespace Notebook {
int Pages(); int Pages();
Directories::Controller& directories() { return directories_; } Directories::Controller& directories() { return directories_; }
Gtk::Paned& view(); Gtk::Paned& view();
bool GeneratePopup(Gtk::Window* window); bool GeneratePopup();
void Search(bool forward); void Search(bool forward);
const Source::Config& source_config() { return source_config_; } const Source::Config& source_config() { return source_config_; }
bool OnMouseRelease(GdkEventButton* button); bool OnMouseRelease(GdkEventButton* button);
bool OnKeyRelease(GdkEventKey* key);
protected: protected:
void TextViewHandlers(Gtk::TextView& textview); void TextViewHandlers(Gtk::TextView& textview);
void PopupSelectHandler(Gtk::Dialog &popup, void PopupSelectHandler(Gtk::Dialog &popup,
@ -94,6 +95,7 @@ namespace Notebook {
Glib::RefPtr<Gtk::Clipboard> refClipboard_; Glib::RefPtr<Gtk::Clipboard> refClipboard_;
bool ispopup; bool ispopup;
Gtk::Dialog popup_; Gtk::Dialog popup_;
Gtk::Window* window_;
}; // class controller }; // class controller
} // namespace Notebook } // namespace Notebook
#endif // JUCI_NOTEBOOK_H_ #endif // JUCI_NOTEBOOK_H_

10
juci/window.cc

@ -4,7 +4,7 @@ Window::Window() :
window_box_(Gtk::ORIENTATION_VERTICAL), window_box_(Gtk::ORIENTATION_VERTICAL),
main_config_(), main_config_(),
keybindings_(main_config_.keybindings_cfg()), keybindings_(main_config_.keybindings_cfg()),
notebook_(keybindings(), main_config_.source_cfg(), main_config_.dir_cfg()), notebook_(*this,keybindings(), main_config_.source_cfg(), main_config_.dir_cfg()),
menu_(keybindings()) { menu_(keybindings()) {
set_title("juCi++"); set_title("juCi++");
set_default_size(600, 400); set_default_size(600, 400);
@ -35,8 +35,6 @@ Window::Window() :
OnSaveFileAs(); OnSaveFileAs();
}); });
notebook_.CurrentTextView().signal_key_release_event().
connect(sigc::mem_fun(*this,&Window::OnKeyRelease),false);
this->signal_button_release_event(). this->signal_button_release_event().
connect(sigc::mem_fun(*this,&Window::OnMouseRelease),false); connect(sigc::mem_fun(*this,&Window::OnMouseRelease),false);
terminal_.Terminal().signal_button_release_event(). terminal_.Terminal().signal_button_release_event().
@ -169,12 +167,6 @@ void Window::OnSaveFileAs(){
} }
} }
} }
bool Window::OnKeyRelease(GdkEventKey* key){
if(key->keyval==46){
return notebook_.GeneratePopup(this);
}
return false;
}
bool Window::OnMouseRelease(GdkEventButton *button){ bool Window::OnMouseRelease(GdkEventButton *button){
return notebook_.OnMouseRelease(button); return notebook_.OnMouseRelease(button);
} }

1
juci/window.h

@ -29,7 +29,6 @@ public:
void OnOpenFile(); void OnOpenFile();
void OnFileOpenFolder(); void OnFileOpenFolder();
void OnSaveFileAs(); void OnSaveFileAs();
bool OnKeyRelease(GdkEventKey* key);
bool OnMouseRelease(GdkEventButton* button); bool OnMouseRelease(GdkEventButton* button);
}; };

Loading…
Cancel
Save