From a8d19b940fd597cae22413cdab5555168bfdc551 Mon Sep 17 00:00:00 2001
From: Humdinger
Date: Thu, 5 May 2016 10:42:53 +0200
Subject: [PATCH 1/6] Bugfix and live settings for folders and rules
Major bug fixed: The RuleEditWindow didn't inform the RuleTab that
a rule was added, edited or removed.
Bug fixed: Dropping files resulted in ProcessFiles() being run twice. Now
we run it only once in ReadyToRun().
Update the button to start/stop AutoFiler on tab creation. Eliminates a
possible delay of 0.5s until the BMessageRunner comes around for the first
time.
The AutoFiler folder settings and the Filer rules are now saved and applied
live and don't wait for the window to close. The only setting saved on close
is now the Autofiler autorun checkbox.
---
sources/AutoFilerTab.cpp | 8 ++++----
sources/DropZoneTab.cpp | 1 +
sources/RefStorage.cpp | 1 -
sources/RuleEditWindow.cpp | 12 ++++--------
sources/RuleEditWindow.h | 3 ++-
sources/RuleTab.cpp | 28 ++++++++++++----------------
sources/RuleTab.h | 1 -
sources/main.cpp | 1 -
8 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/sources/AutoFilerTab.cpp b/sources/AutoFilerTab.cpp
index dfa2c43..4ef9ca9 100644
--- a/sources/AutoFilerTab.cpp
+++ b/sources/AutoFilerTab.cpp
@@ -143,12 +143,13 @@ AutoFilerTab::AttachedToWindow()
fFolderList->SetTarget(this);
fFilePanel->SetTarget(this);
+ BMessenger messenger(this);
if (fFolderList->CountItems() > 0) {
- BMessenger messenger(this);
BMessage msg(MSG_FOLDER_SELECTED);
messenger.SendMessage(&msg);
}
BMessage msg(MSG_UPDATE_LABEL);
+ messenger.SendMessage(&msg);
fRunner = new BMessageRunner(this, &msg, 0.5 * 6000000); // x * seconds
BView::AttachedToWindow();
@@ -160,8 +161,6 @@ AutoFilerTab::DetachedFromWindow()
{
if (!fDirtySettings)
return;
-
- SaveFolders();
// save autorun value
bool autorun = (fAutorunBox->Value() == B_CONTROL_ON);
@@ -310,7 +309,8 @@ AutoFilerTab::UpdateAutoFilerLabel()
void
AutoFilerTab::UpdateAutoFilerFolders()
{
- fDirtySettings = true;
+ SaveFolders();
+
// if AutoFiler is running, tell it to refresh its folders
if (be_roster->IsRunning(kAutoFilerSignature)) {
BMessage msg(MSG_REFRESH_FOLDERS);
diff --git a/sources/DropZoneTab.cpp b/sources/DropZoneTab.cpp
index 379248f..0a758e4 100644
--- a/sources/DropZoneTab.cpp
+++ b/sources/DropZoneTab.cpp
@@ -153,6 +153,7 @@ DropZone::MessageReceived(BMessage* msg)
if (msg->WasDropped()) {
msg->what = B_REFS_RECEIVED;
be_roster->Launch(kFilerSignature, msg);
+ return;
}
switch (msg->what)
{
diff --git a/sources/RefStorage.cpp b/sources/RefStorage.cpp
index 86a36df..44d80b7 100644
--- a/sources/RefStorage.cpp
+++ b/sources/RefStorage.cpp
@@ -68,7 +68,6 @@ LoadFolders()
if (refholder)
gRefStructList.AddItem(refholder);
}
-
return status;
}
diff --git a/sources/RuleEditWindow.cpp b/sources/RuleEditWindow.cpp
index de53fc6..5764478 100644
--- a/sources/RuleEditWindow.cpp
+++ b/sources/RuleEditWindow.cpp
@@ -22,11 +22,12 @@
#include "TestView.h"
-RuleEditWindow::RuleEditWindow(BRect& rect, FilerRule* rule)
+RuleEditWindow::RuleEditWindow(BRect& rect, FilerRule* rule, BHandler* caller)
:
BWindow(rect, "Edit rule", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_CLOSE_ON_ESCAPE),
- fOriginalID(-1)
+ fOriginalID(-1),
+ fCaller(caller)
{
if (rule)
fOriginalID = rule->GetID();
@@ -340,10 +341,5 @@ RuleEditWindow::SendRuleMessage()
msg.AddPointer("item", rule);
msg.AddInt64("id", fOriginalID);
- for (int32 i = 0; i < be_app->CountWindows(); i++)
- {
- BWindow* win = be_app->WindowAt(i);
- if (strcmp(win->Title(), "Filer settings") == 0)
- win->PostMessage(&msg);
- }
+ fCaller->Looper()->PostMessage(&msg, fCaller);
}
diff --git a/sources/RuleEditWindow.h b/sources/RuleEditWindow.h
index ea35abc..a33ef64 100644
--- a/sources/RuleEditWindow.h
+++ b/sources/RuleEditWindow.h
@@ -20,7 +20,7 @@ class TestView;
class RuleEditWindow : public BWindow
{
public:
- RuleEditWindow(BRect& rect, FilerRule* rule);
+ RuleEditWindow(BRect& rect, FilerRule* rule, BHandler* caller);
~RuleEditWindow();
void MessageReceived(BMessage* msg);
@@ -50,6 +50,7 @@ class RuleEditWindow : public BWindow
BButton* fHelp;
int64 fOriginalID;
+ BHandler* fCaller;
BList fTestList;
BList fActionList;
diff --git a/sources/RuleTab.cpp b/sources/RuleTab.cpp
index ffa4b2f..21efc93 100644
--- a/sources/RuleTab.cpp
+++ b/sources/RuleTab.cpp
@@ -166,15 +166,6 @@ RuleTab::AttachedToWindow()
}
-void
-RuleTab::DetachedFromWindow()
-{
- if (fChanges)
- SaveRules(fRuleList);
- MakeEmpty();
-}
-
-
void
RuleTab::MessageReceived(BMessage* message)
{
@@ -190,7 +181,7 @@ RuleTab::MessageReceived(BMessage* message)
frame.bottom = frame.top + 300;
frame.OffsetBy(60, 30);
- RuleEditWindow* rulewin = new RuleEditWindow(frame, NULL);
+ RuleEditWindow* rulewin = new RuleEditWindow(frame, NULL, this);
rulewin->Show();
break;
}
@@ -205,29 +196,30 @@ RuleTab::MessageReceived(BMessage* message)
FilerRule* rule = fRuleList->ItemAt(
fRuleItemList->CurrentSelection());
- RuleEditWindow* rulewin = new RuleEditWindow(frame, rule);
+ RuleEditWindow* rulewin = new RuleEditWindow(frame, rule, this);
rulewin->Show();
break;
}
case MSG_ADD_RULE:
{
- fChanges = true;
FilerRule* item;
if (message->FindPointer("item", (void**)&item) == B_OK)
AddRule(item);
+
+ SaveRules(fRuleList);
break;
}
case MSG_REMOVE_RULE:
{
- fChanges = true;
if (fRuleItemList->CurrentSelection() >= 0)
RemoveRule((RuleItem*)fRuleItemList->ItemAt(
fRuleItemList->CurrentSelection()));
+
+ SaveRules(fRuleList);
break;
}
case MSG_UPDATE_RULE:
{
- fChanges = true;
FilerRule* rule;
if (message->FindPointer("item", (void**)&rule) == B_OK)
{
@@ -248,6 +240,8 @@ RuleTab::MessageReceived(BMessage* message)
}
delete rule;
}
+
+ SaveRules(fRuleList);
break;
}
case MSG_REVERT:
@@ -276,24 +270,26 @@ RuleTab::MessageReceived(BMessage* message)
}
case MSG_MOVE_RULE_UP:
{
- fChanges = true;
int32 selection = fRuleItemList->CurrentSelection();
if (selection < 1)
break;
fRuleItemList->SwapItems(selection, selection - 1);
fRuleList->SwapItems(selection, selection - 1);
+
+ SaveRules(fRuleList);
break;
}
case MSG_MOVE_RULE_DOWN:
{
- fChanges = true;
int32 selection = fRuleItemList->CurrentSelection();
if (selection > fRuleItemList->CountItems() - 1)
break;
fRuleItemList->SwapItems(selection, selection + 1);
fRuleList->SwapItems(selection, selection + 1);
+
+ SaveRules(fRuleList);
break;
}
default:
diff --git a/sources/RuleTab.h b/sources/RuleTab.h
index 0a877e5..bd9512a 100644
--- a/sources/RuleTab.h
+++ b/sources/RuleTab.h
@@ -25,7 +25,6 @@ class RuleTab : public BView
~RuleTab();
virtual void AttachedToWindow();
- virtual void DetachedFromWindow();
void MessageReceived(BMessage* message);
private:
diff --git a/sources/main.cpp b/sources/main.cpp
index 51d72a2..fe2e6f8 100644
--- a/sources/main.cpp
+++ b/sources/main.cpp
@@ -93,7 +93,6 @@ App::RefsReceived(BMessage* msg)
printf("No files given could be processed. Exiting.\n");
fQuitRequested = true;
}
- ProcessFiles();
}
From 69def19625740357fc1f3ae55cbfd4c605b39d6b Mon Sep 17 00:00:00 2001
From: Humdinger
Date: Thu, 5 May 2016 10:52:19 +0200
Subject: [PATCH 2/6] Cleanup
Exchanged the old "PrefsWindow" to "RuleTab" in the DB calls.
---
sources/RuleRunner.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/sources/RuleRunner.cpp b/sources/RuleRunner.cpp
index 3f4f516..881dc4e 100644
--- a/sources/RuleRunner.cpp
+++ b/sources/RuleRunner.cpp
@@ -1053,7 +1053,7 @@ SaveRules(BObjectList* ruleList)
// While we could use other means of obtaining table names, this table is also
// used for maintaining the order of the rules, which must be preserved
DBCommand(db,"create table RuleList (ruleid int primary key, name varchar);",
- "PrefsWindow::SaveRules");
+ "RuleTab::SaveRules");
BString command;
@@ -1077,11 +1077,11 @@ SaveRules(BObjectList* ruleList)
<< "(entrytype varchar, testtype varchar, testmode varchar,
testvalue varchar, attrtype varchar, attrtypename varchar,
attrpublicname varchar);";
- DBCommand(db, command.String(), "PrefsWindow::SaveRules");
+ DBCommand(db, command.String(), "RuleTab::SaveRules");
command = "insert into RuleList values(";
command << i << ",'" << tablename << "');";
- DBCommand(db, command.String(), "PrefsWindow::SaveRules");
+ DBCommand(db, command.String(), "RuleTab::SaveRules");
for (int32 j = 0; j < rule->CountTests(); j++)
{
@@ -1108,7 +1108,7 @@ SaveRules(BObjectList* ruleList)
<< "', '" << EscapeIllegalCharacters(attrName.String())
<< "');";
- DBCommand(db, command.String(), "PrefsWindow::SaveRules:save test");
+ DBCommand(db, command.String(), "RuleTab::SaveRules:save test");
}
for (int32 j = 0; j < rule->CountActions(); j++)
@@ -1127,7 +1127,7 @@ SaveRules(BObjectList* ruleList)
<< "', '"
<< "', '" << EscapeIllegalCharacters(value.String())
<< "', '', '', '');";
- DBCommand(db, command.String(), "PrefsWindow::SaveRules:save action");
+ DBCommand(db, command.String(), "RuleTab::SaveRules:save action");
}
}
db.close();
@@ -1156,7 +1156,7 @@ LoadRules(BObjectList* ruleList)
CppSQLite3Query query;
query = DBQuery(db,"select name from RuleList order by ruleid;",
- "PrefsWindow::LoadRules");
+ "RuleTab::LoadRules");
BString command;
while (!query.eof())
@@ -1185,7 +1185,7 @@ LoadRules(BObjectList* ruleList)
// Now comes the fun(?) part: loading the tests and actions. Joy. :/
command = "select * from ";
command << rulename << " where entrytype = 'test';";
- query = DBQuery(db, command.String(), "PrefsWindow::LoadRules");
+ query = DBQuery(db, command.String(), "RuleTab::LoadRules");
while (!query.eof())
{
@@ -1216,7 +1216,7 @@ LoadRules(BObjectList* ruleList)
command = "select * from ";
command << rulename << " where entrytype = 'action';";
- query = DBQuery(db, command.String(), "PrefsWindow::LoadRules");
+ query = DBQuery(db, command.String(), "RuleTab::LoadRules");
while (!query.eof())
{
From 0f00834081b82d040d44038d661815595072b8bb Mon Sep 17 00:00:00 2001
From: Humdinger
Date: Thu, 5 May 2016 11:09:32 +0200
Subject: [PATCH 3/6] Update documentation
---
documentation/User Documentation.html | 31 +++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/documentation/User Documentation.html b/documentation/User Documentation.html
index f59fb99..e86105d 100644
--- a/documentation/User Documentation.html
+++ b/documentation/User Documentation.html
@@ -101,6 +101,25 @@
ul {
padding-left: 14px;
}
+
+/* Rounded corner boxes */
+/* Common declarations */
+.box-info {
+ -webkit-border-radius: 10px;
+ -khtml-border-radius: 10px;
+ -moz-border-radius: 10px;
+ border-radius: 10px;
+ border-style: dotted;
+ border-width: thin;
+ border-color: #dcdcdc;
+ padding: 10px 15px 10px 80px;
+ margin-bottom: 15px;
+ margin-top: 15px;
+ min-height: 42px;
+}
+.box-info {
+ background: #e4ffde url(images/alert_info_32.png) 15px 15px no-repeat;
+}
@@ -137,7 +156,10 @@
As described above under 4.), you can drag&drop files onto the Dropzone to have them processed according to your set of rules. If you'd like to embed this Dropzone into the Desktop, click the button Replicate dropzone….
-It opens a window to resize the dropzone to fit your needs. When that's done, drag the little Replicant handle in the bottom-right corner onto your Desktop. Make sure to have in the Deskbar menu activated. Once on the Desktop, right-click the Replicant's handle for a menu to remove it again.
+It opens a window to resize the dropzone to fit your needs. When that's done, drag the little Replicant handle in the bottom-right corner onto your Desktop. Make sure to have in the Deskbar menu activated. Once on the Desktop, right-click the Replicant's handle for a menu to remove it again.
+A right-click into the shaded part of the replicated Dropzone offers a menu as a shortcut to .
+
+If you drag files from another partition onto a replicated Dropzone, you'll end up with copies of those files on your Desktop. This is because notifications of dropped files are not only processed by the Replicant, but also by the Tracker sitting below.
@@ -181,11 +203,12 @@
Initial release.
-1.1.0 - 03-05-2016
+1.1.0 - 05-05-2016
-- A new GUI to integrate Filer and AutoFiler settings.
+- A new GUI that integrates Filer and AutoFiler settings.
+- Apply changed settings, rules and monitored folders live.
- Add a button to manually start/stop AutoFiler.
-- Adding a dropzone and make it replicatable.
+
- Add a dropzone and make it replicatable.
- Add user documentation.