From 398694e492f48efd9865ce3682d68ce93e2228c0 Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Thu, 27 May 2010 11:25:12 +0100 Subject: [PATCH] Allow control clicking on the rank stars in the filebrowser toolbar in order to show photos with multiple ranks. For example contol click on the 4th and 5th stars to show photos with rank 4 or 5. Unmodified clicks retain their old behaviour, and clear the multi-rank selection. --- rtgui/filecatalog.cc | 43 ++++++++++++++++++++++++++++++++++++------- rtgui/filecatalog.h | 2 ++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index c29f0c436..d2b2d4c0a 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -97,6 +97,7 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb) : listener(NULL), fslist bRank[i]->set_relief (Gtk::RELIEF_NONE); buttonBar->pack_start (*bRank[i], Gtk::PACK_SHRINK); bCateg[i+2] = bRank[i]->signal_toggled().connect (sigc::bind(sigc::mem_fun(*this, &FileCatalog::categoryButtonToggled), bRank[i])); + bRank[i]->signal_button_press_event().connect (sigc::mem_fun(*this, &FileCatalog::on_my_button_press_event),false); } bRank[0]->set_tooltip_text (M("FILEBROWSER_SHOWRANK1HINT")); bRank[1]->set_tooltip_text (M("FILEBROWSER_SHOWRANK2HINT")); @@ -182,6 +183,12 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb) : listener(NULL), fslist #endif } +bool FileCatalog::on_my_button_press_event(GdkEventButton* event){ + // need to record modifiers on the button press, because signal_toggled does not pass the event. + modifierKey = event->state; + return false; +} + void FileCatalog::exifInfoButtonToggled() { options.showFileNames = exifInfo->get_active(); @@ -584,6 +591,8 @@ void FileCatalog::renameRequested (std::vector tbe) { } void FileCatalog::categoryButtonToggled (Gtk::ToggleButton* b) { + + for (int i=0; i<8; i++) bCateg[i].block (true); @@ -592,19 +601,39 @@ void FileCatalog::categoryButtonToggled (Gtk::ToggleButton* b) { // seek the one pressed for (int i=0; i<8; i++) { - categoryButtons[i]->set_active (categoryButtons[i]==b); + if (! (modifierKey & GDK_CONTROL_MASK)){ // if the contol key was not held, then untoggle other ranks + categoryButtons[i]->set_active (categoryButtons[i]==b); + } if (categoryButtons[i]==b) lastScrollPos = i; } - + + // if you control so that no stars are toggle on, then toggle on the one you clicked + // makes behaviour more natural + if (modifierKey & GDK_CONTROL_MASK){ + int activeCount = 0; + for (int i=0; i<5; i++){ + if (bRank[i]->get_active()) activeCount ++; + } + if (activeCount == 0){ + b->set_active(); + } + } + // change the images of the buttons to reflect current ranking for (int i=0; i<5; i++) bRank[i]->set_image (*igranked[i]); - for (int i=0; i<5; i++) - if (b==bRank[i]) - for (int j=0; j<=i; j++) - bRank[j]->set_image (*iranked[j]); - + if (! (modifierKey & GDK_CONTROL_MASK)){ + for (int i=0; i<5; i++) + if (b==bRank[i]) + for (int j=0; j<=i; j++) + bRank[j]->set_image (*iranked[j]); + }else{ // if we are in control clicking mode, then light up the toggle bttons + for (int i=0; i<5; i++){ + if(bRank[i]->get_active()) bRank[i]->set_image (*iranked[i]); + } + } + fileBrowser->applyFilter (getFilter ()); // rearrange panels according to the selected filter diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index 73b5ff8e2..35e43fb09 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -132,6 +132,7 @@ class FileCatalog : public Gtk::VBox, #endif std::vector fileNameList; std::set editedFiles; + guint modifierKey; // any modifiers held when rank button was pressed void addAndOpenFile (const Glib::ustring& fname); void checkAndAddFile (Glib::RefPtr info); @@ -177,6 +178,7 @@ class FileCatalog : public Gtk::VBox, void setFilterPanel (FilterPanel* fpanel); void exifInfoButtonToggled(); void categoryButtonToggled (Gtk::ToggleButton* b); + bool on_my_button_press_event(GdkEventButton* event); void filterChanged (); void runFilterDialog ();