Skip to content

Commit

Permalink
Merge pull request #7 from humdingerb/settings
Browse files Browse the repository at this point in the history
Bugfixes, improvements
  • Loading branch information
waddlesplash committed May 5, 2016
2 parents b0c2849 + 8d010bb commit 44b9b08
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 86 deletions.
35 changes: 3 additions & 32 deletions README
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
Filer v1.0 Beta 3
Filer is an automatic file organizer. It takes the files it's opened with or that are dropped on it and moves, renames, copies or does all sorts of other things with them according to rules created by the user.

Filer is an automatic filer organizer. It can move, rename, copy, and much, much more. You could even make it bark. ;-) For extensive help and tips, click on the Help button from with the program.
Filer is accompanied by AutoFiler. Instead of working on a set of files provided by the user, it can be started (automatically with Haiku) to monitor certain folders and deal with new files appearing there according to the user-defined rules.

About this version

Some more bugs were found in the second beta release and a suggested feature was added. Changes since Beta 2:

1) Fixed a bug which caused all Type tests to fail

2) Removed a crash after removing a rule

3) Added the AutoFiler, a helper program which watches folders and runs the Filer on them whenever a new file appears in one of them.

Please e-mail me if you find any bugs.

--DarkWyrm
[email protected]


Usage

Double-click on the Filer to open the list of organization rules. To make it organize files, just drag and drop one or more files onto its icon, right click on a file and choose it from the Open With menu, or give it a list of file names from the Terminal. If a rule doesn't work right, try running it from the Terminal to see what it's doing as it processes your files.


Features

- Choose from a file's name, size, location, type, or attributes as a source for conditions for organization

- A wide variety of possible actions for files which match

- Use substitution patterns in actions for more flexible renaming and organizing

- Wildly extensible through the use of Terminal commands
For more information, see the accompanying documentation and rule making reference in the documentation folder.
29 changes: 27 additions & 2 deletions documentation/Rule-Making Reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Humdinger <[email protected]>
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
Expand Down Expand Up @@ -98,6 +99,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;
}
</style>

</head>
Expand All @@ -110,12 +130,15 @@
</div>
<hr />
<p><br /></p>
<p>You will probably find most parts of the Filer pretty self-explanatory, please refer to <a href="User%20Documentation.html">Filer's User Documentation</a> for more information.</p>
<p>To really get power out of it, you'll want to read the information below, though. There are also a number of useful examples to get you going.</p>
<p>You will probably find most parts of the Filer pretty self-explanatory, please refer to <a href="User%20Documentation.html">Filer's User Documentation</a> for more information.<br />
To really get power out of it, you'll want to read the information below, though. There are also a number of useful examples to get you going.</p>

<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="rule-conditions" name="rule-conditions">Rule Conditions</a></h2>
<p>You will need at least one condition for the rule to test for. It can be the type of file, something about its name, how big it is, or some other attribute. These other attributes can be things like someone's nickname kept in a Person file or the e-mail address in the To: field of an e-mail. Note that these can appear on just about any kind of file, but generally will only be found on the kind of file you expect it to be on. A rule will only match if all the conditions you set are met.</p>
<div class="box-info">If a rule doesn't work right, try running Filer from the Terminal to see what it's doing as it processes your files.</div>

<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="rule-actions" name="rule-actions">Rule Actions</a></h2>
Expand All @@ -128,6 +151,7 @@ <h2>
<tr><td class="onelinetop"><span class="key">Delete it</span></td><td></td><td>Only if you're sure of yourself and hate a cluttered Trash can.</td></tr>
<tr><td class="onelinetop"><span class="key">Terminal command…</span></td><td></td><td>For experts. Run a command just as if you typed it into a Terminal. Substitutions (see below) are performed before the command is executed. This can make the Filer automatically do all sorts of things it couldn't do otherwise. If you move or rename the file this way, you'll need to do everything else with more Terminal command actions or a shell script.</td></tr>
</table>

<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="substitutions" name="substitutions">Substitutions</a></h2>
Expand All @@ -144,6 +168,7 @@ <h2>
<tr><td class="onelinetop">%TIME%</td><td></td><td>Current time using 24-hour time.</td></tr>
<tr><td class="onelinetop">%ATTR:xxxx%</td><td></td><td>An extended attribute of the file. The technical name for the attribute is put between the colon and the second %. At this point, unfortunately, the case-sensitive, technical name of the attribute must be used. For example, an e-mail address attribute is META:email. This can be found in the FileTypes preferences application by choosing the type of file it is normally found on and double-clicking on it in the "Extra attributes" box. In the window that appears, it will be in the box marked "Internal name".</td></tr>
</table>

<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="common-attributes" name="common-attributes">Common Attributes</a></h2>
Expand Down
34 changes: 29 additions & 5 deletions documentation/User Documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>

</head>
Expand All @@ -113,7 +132,7 @@
</div>
<hr />
<p><br /></p>
<p><i>Filer</i> is an automatic file organizer. It takes the files it's opened with or that are dropped on its icon and moves, renames, copies or does all sorts of other things with them according to rules created by the user.</p>
<p><i>Filer</i> is an automatic file organizer. It takes the files it's opened with or that are dropped on it and moves, renames, copies or does all sorts of other things with them according to rules created by the user.</p>
<p><i>Filer</i> is accompanied by <i>AutoFiler</i>. Instead of working on a set of files provided by the user, it can be started (automatically with Haiku) to monitor certain folders and deal with new files appearing there according to the user-defined rules.</p>

<h2>
Expand All @@ -137,7 +156,10 @@ <h2>
<img src="./images/filer_dropzone.png" alt="Filer's dropzone" />
</div>
<p>As described above under 4.), you can drag&amp;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 <span class="button">Replicate dropzone…</span>.<br />
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 <span class="menu">Show replicants</span> in the Deskbar menu activated. Once on the Desktop, right-click the Replicant's handle for a menu to remove it again.</p>
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 <span class="menu">Show replicants</span> in the Deskbar menu activated. Once on the Desktop, right-click the Replicant's handle for a menu to remove it again.<br />
A right-click into the shaded part of the replicated Dropzone offers a menu as a shortcut to <span class="menu">Open Filer…</span>.</p>
<div class="box-info">
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.</div>

<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
Expand Down Expand Up @@ -181,11 +203,13 @@ <h2>
<li>Initial release.</li>
</ul>

<p><b>1.1.0</b> - <i>03-05-2016</i></p>
<p><b>1.1.0</b> - <i>05-05-2016</i></p>
<ul>
<li>A new GUI to integrate Filer and AutoFiler settings.</li>
<li>A new GUI that integrates Filer and AutoFiler settings.</li>
<li>Some usability improvements.</li>
<li>Apply changed settings, rules and monitored folders live.</li>
<li>Add a button to manually start/stop AutoFiler.</li>
<li>Adding a dropzone and make it replicatable.
<li>Add a dropzone and make it replicatable.
<li>Add user documentation.</li></li>
</ul>
</body>
Expand Down
Binary file added documentation/images/alert_info_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 55 additions & 8 deletions sources/AutoFilerTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ AutoFilerTab::AutoFilerTab()
B_DIRECTORY_NODE, false, NULL, fRefFilter);
BMessage panelMsg(MSG_FOLDER_CHOSEN);
fFilePanel->SetMessage(&panelMsg);

gRefLock.Lock();
for (int32 i = 0; i < gRefStructList.CountItems(); i++)
{
RefStorage* refholder = (RefStorage*)gRefStructList.ItemAt(i);
fFolderList->AddItem(new BStringItem(BPath(&refholder->ref).Path()));
}
gRefLock.Unlock();

fFolderList->MakeFocus();
if (fFolderList->CountItems() > 0)
fFolderList->Select(0L);
Expand Down Expand Up @@ -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();
Expand All @@ -160,8 +161,6 @@ AutoFilerTab::DetachedFromWindow()
{
if (!fDirtySettings)
return;

SaveFolders();

// save autorun value
bool autorun = (fAutorunBox->Value() == B_CONTROL_ON);
Expand All @@ -182,6 +181,22 @@ AutoFilerTab::DetachedFromWindow()
void
AutoFilerTab::MessageReceived(BMessage* msg)
{
if (msg->WasDropped()) {
BMessenger msgr(this);
entry_ref tempRef;
int32 i = 0;
while (msg->FindRef("refs", i, &tempRef) == B_OK)
{
BEntry entry(&tempRef);
if (entry.Exists()) {
BMessage newMsg(MSG_FOLDER_CHOSEN);
newMsg.AddRef("refs", &tempRef);
msgr.SendMessage(&newMsg);
} else
printf("Couldn't find file %s\n",tempRef.name);
i++;
}
}
switch (msg->what)
{
case MSG_AUTOFILER_AUTORUN:
Expand Down Expand Up @@ -228,6 +243,9 @@ AutoFilerTab::MessageReceived(BMessage* msg)
BStringItem* item = (BStringItem*)fFolderList->RemoveItem(selection);
delete item;

int32 count = fFolderList->CountItems();
fFolderList->Select((selection > count - 1) ? count - 1 : selection);

gRefLock.Lock();
RefStorage* refholder = (RefStorage*)gRefStructList.RemoveItem(selection);
delete refholder;
Expand All @@ -250,11 +268,23 @@ AutoFilerTab::MessageReceived(BMessage* msg)
int32 index;
if (msg->FindInt32("index", &index) != B_OK)
index = -1;

entry_ref ref;
if (msg->FindRef("refs", &ref) != B_OK)
break;


BEntry entry(&ref);
BPath path;
entry.GetPath(&path);
if (!entry.IsDirectory()) {
path.GetParent(&path);
get_ref_for_path(path.Path(), &ref);
}

BString newpath(path.Path());
if (!IsFolderUnique(newpath))
return;

BStringItem* item = (BStringItem*)fFolderList->ItemAt(index);
if (item) {
gRefLock.Lock();
Expand Down Expand Up @@ -282,6 +312,22 @@ AutoFilerTab::MessageReceived(BMessage* msg)
}


bool
AutoFilerTab::IsFolderUnique(BString newpath)
{
if (fFolderList->IsEmpty())
return true;

bool unique = true;
for (int i = 0; i < fFolderList->CountItems(); i++) {
BStringItem* sItem = (BStringItem*)fFolderList->ItemAt(i);
if (newpath.Compare(sItem->Text()) == 0)
unique = false;
}
return unique;
}


void
AutoFilerTab::ToggleAutoFiler()
{
Expand Down Expand Up @@ -310,7 +356,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);
Expand Down
1 change: 1 addition & 0 deletions sources/AutoFilerTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AutoFilerTab : public BView
void EnableAutorun();
void DisableAutorun();

bool IsFolderUnique(BString newpath);
void ToggleAutoFiler();
void UpdateAutoFilerLabel();

Expand Down
1 change: 1 addition & 0 deletions sources/DropZoneTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion sources/RefStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ LoadFolders()
if (refholder)
gRefStructList.AddItem(refholder);
}

return status;
}

Expand Down
12 changes: 4 additions & 8 deletions sources/RuleEditWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion sources/RuleEditWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -50,6 +50,7 @@ class RuleEditWindow : public BWindow
BButton* fHelp;

int64 fOriginalID;
BHandler* fCaller;

BList fTestList;
BList fActionList;
Expand Down
Loading

0 comments on commit 44b9b08

Please sign in to comment.