Changeset 3e869acf2eb279fefaba15768ca18932c148968c

Show
Ignore:
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:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • inc/window.hpp

    rc46ecec r3e869ac  
    2323#include <gtkmm/paned.h> 
    2424#include <gtkmm/frame.h> 
     25#include <gtkmm/messagedialog.h> 
    2526#include <obby/local_buffer.hpp> 
     27#include "features.hpp" 
    2628#include "icon.hpp" 
    2729#include "config.hpp" 
     
    3436#include "chat.hpp" 
    3537#include "statusbar.hpp" 
    36 #include "features.hpp" 
     38#include "dragdrop.hpp" 
    3739#ifdef WITH_HOWL 
    3840#include <obby/zeroconf.hpp> 
     
    4850        ~Window(); 
    4951 
     52        /** Offers a pointer to the currently visible document. If the user 
     53         * is not subscribed to a document, NULL is returned. 
     54         */ 
    5055        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); 
    5165protected: 
    5266        // Gtk::Window overrides 
     
    90104        void on_quit(); 
    91105 
    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  
    99106        // Obby signal handlers 
    100107        void on_obby_close(); 
     
    110117        void apply_preferences(); 
    111118        void update_title_bar(); 
    112         void open_local_file(const Glib::ustring& file); 
    113         void save_local_file(Document& doc, const Glib::ustring& file); 
    114119        void close_document(DocWindow& doc); 
    115120        void display_error(const Glib::ustring& message, 
     
    142147        StatusBar m_statusbar; 
    143148 
     149        /** Drag+Drop handler 
     150         */ 
     151        std::auto_ptr<DragDrop> m_dnd; 
     152 
    144153        // obby 
    145154        std::auto_ptr<obby::local_buffer> m_buffer; 
  • src/window.cpp

    rc46ecec r3e869ac  
    273273 
    274274        // 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) ); 
    278276 
    279277        m_header.group_session->set_sensitive(true); 
     
    334332void Gobby::Window::obby_end() 
    335333{ 
    336         // No drag and drop anymore 
    337         drag_dest_unset(); 
    338  
    339334        // Nothing to do if no buffer is open 
    340335        if(!m_buffer.get() ) return; 
     336 
     337        // Remove DND handler 
     338        m_dnd.reset(NULL); 
    341339 
    342340        // Tell GUI components that the session ended 
     
    917915} 
    918916 
    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  
    956917void Gobby::Window::on_obby_close() 
    957918{