Changeset 3e869acf2eb279fefaba15768ca18932c148968c
- Timestamp:
- 01/06/07 23:54:38 (6 years ago)
- Author:
- Philipp Kern <phil@…>
- Parents:
- 83656f5e55cda4f7a31f2911e7c2e36ebb87e0b3
- Children:
- 24041fba2be0714c5821951abe3c0ab8fa76a094
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:54:38Z+0000
- Message:
-
[project @ Win32 Drag+Drop support [fixes #71]]
Original author: Armin Burgmeier <armin@…>
Date: 2005-11-17 12:52:24+00:00
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rc46ecec
|
r3e869ac
|
|
| 23 | 23 | #include <gtkmm/paned.h> |
| 24 | 24 | #include <gtkmm/frame.h> |
| | 25 | #include <gtkmm/messagedialog.h> |
| 25 | 26 | #include <obby/local_buffer.hpp> |
| | 27 | #include "features.hpp" |
| 26 | 28 | #include "icon.hpp" |
| 27 | 29 | #include "config.hpp" |
| … |
… |
|
| 34 | 36 | #include "chat.hpp" |
| 35 | 37 | #include "statusbar.hpp" |
| 36 | | #include "features.hpp" |
| | 38 | #include "dragdrop.hpp" |
| 37 | 39 | #ifdef WITH_HOWL |
| 38 | 40 | #include <obby/zeroconf.hpp> |
| … |
… |
|
| 48 | 50 | ~Window(); |
| 49 | 51 | |
| | 52 | /** Offers a pointer to the currently visible document. If the user |
| | 53 | * is not subscribed to a document, NULL is returned. |
| | 54 | */ |
| 50 | 55 | Document* get_current_document(); |
| | 56 | |
| | 57 | /** Opens a document containing the content of a file mounted on the |
| | 58 | * local filesystem. |
| | 59 | */ |
| | 60 | void open_local_file(const Glib::ustring& file); |
| | 61 | |
| | 62 | /** Saves an existing document to the given path. |
| | 63 | */ |
| | 64 | void save_local_file(Document& doc, const Glib::ustring& file); |
| 51 | 65 | protected: |
| 52 | 66 | // Gtk::Window overrides |
| … |
… |
|
| 90 | 104 | void on_quit(); |
| 91 | 105 | |
| 92 | | // Drag and drop |
| 93 | | virtual void on_drag_data_received( |
| 94 | | const Glib::RefPtr<Gdk::DragContext>& context, |
| 95 | | int x, int y, const Gtk::SelectionData& data, |
| 96 | | guint info, guint time |
| 97 | | ); |
| 98 | | |
| 99 | 106 | // Obby signal handlers |
| 100 | 107 | void on_obby_close(); |
| … |
… |
|
| 110 | 117 | void apply_preferences(); |
| 111 | 118 | void update_title_bar(); |
| 112 | | void open_local_file(const Glib::ustring& file); |
| 113 | | void save_local_file(Document& doc, const Glib::ustring& file); |
| 114 | 119 | void close_document(DocWindow& doc); |
| 115 | 120 | void display_error(const Glib::ustring& message, |
| … |
… |
|
| 142 | 147 | StatusBar m_statusbar; |
| 143 | 148 | |
| | 149 | /** Drag+Drop handler |
| | 150 | */ |
| | 151 | std::auto_ptr<DragDrop> m_dnd; |
| | 152 | |
| 144 | 153 | // obby |
| 145 | 154 | std::auto_ptr<obby::local_buffer> m_buffer; |
-
|
rc46ecec
|
r3e869ac
|
|
| 273 | 273 | |
| 274 | 274 | // Accept drag and drop of files into the gobby window |
| 275 | | std::list<Gtk::TargetEntry> targets; |
| 276 | | targets.push_back(Gtk::TargetEntry("text/uri-list") ); |
| 277 | | drag_dest_set(targets); |
| | 275 | m_dnd.reset(new DragDrop(*this) ); |
| 278 | 276 | |
| 279 | 277 | m_header.group_session->set_sensitive(true); |
| … |
… |
|
| 334 | 332 | void Gobby::Window::obby_end() |
| 335 | 333 | { |
| 336 | | // No drag and drop anymore |
| 337 | | drag_dest_unset(); |
| 338 | | |
| 339 | 334 | // Nothing to do if no buffer is open |
| 340 | 335 | if(!m_buffer.get() ) return; |
| | 336 | |
| | 337 | // Remove DND handler |
| | 338 | m_dnd.reset(NULL); |
| 341 | 339 | |
| 342 | 340 | // Tell GUI components that the session ended |
| … |
… |
|
| 917 | 915 | } |
| 918 | 916 | |
| 919 | | /* Drag and Drop */ |
| 920 | | void Gobby::Window::on_drag_data_received( |
| 921 | | const Glib::RefPtr<Gdk::DragContext>& context, |
| 922 | | int x, int y, const Gtk::SelectionData& data, |
| 923 | | guint info, guint time |
| 924 | | ) |
| 925 | | { |
| 926 | | // We only accept uri-lists as new files to open |
| 927 | | if(data.get_target() == "text/uri-list") |
| 928 | | { |
| 929 | | // Get files by dragdata |
| 930 | | std::vector<std::string> files = data.get_uris(); |
| 931 | | //std::unique(files.begin(), files.end() ); |
| 932 | | |
| 933 | | // Open all of them |
| 934 | | for(std::vector<std::string>::iterator iter = files.begin(); |
| 935 | | iter != files.end(); |
| 936 | | ++ iter) |
| 937 | | { |
| 938 | | try |
| 939 | | { |
| 940 | | // Convert URI to filename |
| 941 | | open_local_file( |
| 942 | | Glib::filename_from_uri(*iter) ); |
| 943 | | } |
| 944 | | catch(Glib::ConvertError& e) |
| 945 | | { |
| 946 | | // Show any errors while converting a file |
| 947 | | display_error(e.what() ); |
| 948 | | } |
| 949 | | } |
| 950 | | } |
| 951 | | |
| 952 | | // Call base function |
| 953 | | Gtk::Window::on_drag_data_received(context, x, y, data, info, time); |
| 954 | | } |
| 955 | | |
| 956 | 917 | void Gobby::Window::on_obby_close() |
| 957 | 918 | { |