Changeset 69c1750dc41ea3051e2a4abb3f653be3536d9ae1

Show
Ignore:
Timestamp:
07/30/2008 12:23:42 PM (4 months ago)
Author:
Dave Foster <daf@minuslab.net>
git-committer:
Dave Foster <daf@minuslab.net> 1217445822 -0400
git-parent:

[40804560fa72d53834c4466eb3c82b688d970089]

git-author:
Dave Foster <daf@minuslab.net> 1217445822 -0400
Message:

Better showing of currently set text.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/NWindow.cc

    r4080456 r69c1750  
    2525#include <sys/wait.h> 
    2626#include "gcs-i18n.h" 
     27#include "Util.h" 
    2728 
    2829#ifdef USE_XINERAMA 
     
    148149        } 
    149150        else 
    150             (*i)[view.record.Description] = Glib::ustring(filename, filename.rfind("/")+1) + "\n<small><i>" + _("Currently set background for") + (*mapiter).first + "</i></small>"
     151            (*i)[view.record.Description] = Util::make_current_set_string(this, filename, (*mapiter).first)
    151152    } 
    152153 
     
    253254                                 
    254255                        this->select_display.add_image_row( video_display_icon, ostr.str(), screen->make_display_name(), on ); 
     256 
     257            map_displays[screen->make_display_name()] = ostr.str(); 
    255258                } 
    256259 
     
    274277                                this->select_display.add_image_row(video_display_icon, _("Full Screen"), "xin_-1", true); 
    275278 
     279                map_displays["xin_-1"] = _("Full Screen"); 
     280 
    276281                                for (int i=0; i<xinerama_num_screens; i++) { 
    277282                                        std::ostringstream ostr, valstr; 
     
    280285                                                         
    281286                                        this->select_display.add_image_row(video_display_icon, ostr.str(), valstr.str(), false); 
     287 
     288                    map_displays[valstr.str()] = ostr.str(); 
    282289                                } 
    283290                                                         
  • src/NWindow.h

    ra5e6749 r69c1750  
    4040 
    4141                void set_default_selections(); 
     42 
     43        std::map<Glib::ustring, Glib::ustring> map_displays;        // a map of current displays on the running instance to their display names 
    4244                 
     45                bool is_multihead; 
     46                bool is_xinerama; 
     47 
    4348        protected: 
    4449                 
     
    5459                void setup_select_boxes(); 
    5560 
    56                 bool is_multihead; 
    57                 bool is_xinerama; 
    58  
    5961#ifdef USE_XINERAMA 
    6062                // xinerama stuff 
  • src/Thumbview.cc

    r4080456 r69c1750  
    169169 */ 
    170170void Thumbview::add_file(std::string filename) { 
     171    Gtk::Window *window = dynamic_cast<Gtk::Window*>(get_toplevel()); 
    171172        Gtk::TreeModel::iterator iter = this->store->append (); 
    172173        Gtk::TreeModel::Row row = *iter; 
     
    181182        { 
    182183            row[record.CurBGOnDisp] = (*i).first; 
    183             row[record.Description] = Glib::ustring(filename, filename.rfind("/")+1) + "\n<i>" + _("Currently set background for") + " " + (*i).first + "</i>"
     184            row[record.Description] = Util::make_current_set_string(window, filename, (*i).first)
    184185        } 
    185186    } 
  • src/Util.cc

    rf593b91 r69c1750  
    2727#include "gcs-i18n.h" 
    2828#include <glib/gprintf.h> 
     29#include "NWindow.h" 
    2930 
    3031namespace Util { 
     
    228229} 
    229230 
    230 
     231/** 
     232 * Determines if the passed display is one that is currently seen by the program. 
     233 * 
     234 * Displays are passed in here to determine if they need to be shown as the "current 
     235 * background". 
     236 */ 
     237bool is_display_relevant(Gtk::Window* window, Glib::ustring display) 
     238
     239    // cast window to an NWindow.  we have to do this to avoid a circular dep 
     240    NWindow *nwindow = dynamic_cast<NWindow*>(window); 
     241    if (!nwindow->is_multihead) 
     242    { 
     243        Glib::ustring curdisp = Gdk::DisplayManager::get()->get_default_display()->get_default_screen()->make_display_name(); 
     244        return (curdisp == display); 
     245    } 
     246 
     247    // window IS multihead, check to see if this display is in the map 
     248    return (nwindow->map_displays.find(display) != nwindow->map_displays.end()); 
     249
     250 
     251/** 
     252 * Makes a string for the UI to indicate it is the currently selected background. 
     253 * 
     254 * Checks to make sure the display is relevant with is_display_relevant(). If it is 
     255 * not relevent, it simply returns the filename. 
     256 * 
     257 * ex: "filename\nCurrently set background for Screen 1" 
     258 */ 
     259Glib::ustring make_current_set_string(Gtk::Window* window, Glib::ustring filename, Glib::ustring display) 
     260
     261    // cast window to an NWindow.  we have to do this to avoid a circular dep 
     262    NWindow *nwindow = dynamic_cast<NWindow*>(window); 
     263     
     264    Glib::ustring shortfile(filename, filename.rfind("/")+1); 
     265    if (!is_display_relevant(window, display)) 
     266        return shortfile; 
     267 
     268    std::ostringstream ostr; 
     269    ostr << shortfile << "\n\n" << "<i>" << _("Currently set background"); 
     270 
     271    if (nwindow->is_multihead) 
     272        ostr << " " << _("for") << " " << nwindow->map_displays[display]; 
     273    
     274    ostr << "</i>"; 
     275 
     276    return ostr.str(); 
     277
     278 
     279
  • src/Util.h

    rc8365d4 r69c1750  
    3333        ArgParser* create_arg_parser(); 
    3434        std::string fix_start_dir(std::string startdir); 
     35 
     36    bool is_display_relevant(Gtk::Window* window, Glib::ustring display); 
     37    Glib::ustring make_current_set_string(Gtk::Window* window, Glib::ustring filename, Glib::ustring display); 
    3538} 
    3639