[passepartout] avoid duplicate handlers for "text/plain"



commit 06cb6c7fd7dc2e20f84480468d80afe833aad1ff
Author: Sven Herzberg <herzi lanedo com>
Date:   Wed Apr 15 16:50:06 2009 +0200

    avoid duplicate handlers for "text/plain"
    
    * src/pptout/docview.cc: don't add this mime type twice
---
 src/pptout/docview.cc |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/pptout/docview.cc b/src/pptout/docview.cc
index ef26c4f..3ae2c30 100644
--- a/src/pptout/docview.cc
+++ b/src/pptout/docview.cc
@@ -381,14 +381,13 @@ bool DocumentView::on_button_press_event(GdkEventButton *event) {
 
           /// \todo move the mime type heuristics elsewhere
           ImageFrame *i_f; RasterFrame *r_f; TextFrame *t_f;
+	  // FIXME: use a virtual function
           if((i_f = dynamic_cast<ImageFrame*>(select))) {
             filename = i_f->get_association();
           } else if((r_f = dynamic_cast<RasterFrame*>(select))) {
             filename = r_f->get_association();
           } else if((t_f = dynamic_cast<TextFrame*>(select))) {
-            TextStream *stream = t_f->get_stream();
-            filename = stream->get_association();
-            mimetypes.push_back("text/plain"); // always enable text editors
+            filename = t_f->get_stream()->get_association();
           } else break;
 
           if(filename.empty())
@@ -398,8 +397,13 @@ bool DocumentView::on_button_press_event(GdkEventButton *event) {
           if(mtype)
             mimetypes.push_back(mtype);
 #endif
-          if(mimetypes.empty())
-            mimetypes.push_back("text/plain");
+          /* this is a fallback for unknown types and always enabled for text items */
+          if(mimetypes.empty() || (t_f = dynamic_cast<TextFrame*>(select)))
+	    {
+	      /* but not if it's already in there - FIXME: consider using a unique-item container */
+	      if (std::find (mimetypes.begin(), mimetypes.end(), "text/plain") == mimetypes.end())
+                mimetypes.push_back("text/plain");
+	    }
 
           popup_menu.items().clear();
           try {
@@ -409,6 +413,8 @@ bool DocumentView::on_button_press_event(GdkEventButton *event) {
                 type++)
               Programs::populate_file_handler_menu(popup_menu,
                                                    filename, *type);
+
+	    /* FIXME: add "Object Properties" menu item to open a nice dialog */
             popup_menu.popup(event->button, event->time);
           }
           catch(const std::exception &e) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]