* Replaced "Mark As New" with a "Mark As…" Tracker add-on that let you choose

among all defined status.
* Note, until bug #4851 is solved, the list Mail shows might differ from the
  one "Mark As…" shows.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33960 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-11-09 13:17:47 +00:00
parent 0a9f301a59
commit 66570f5d3b
6 changed files with 151 additions and 39 deletions
+3 -3
View File
@@ -70,7 +70,7 @@ SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc Devices
; ;
SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations
<preference>Deskbar E-mail FileTypes Fonts Keyboard Keymap Locale Media <preference>Deskbar E-mail FileTypes Fonts Keyboard Keymap Locale Media
Mouse Network OpenGL Printers Screen ScreenSaver Shortcuts Sounds Time Mouse Network OpenGL Printers Screen ScreenSaver Shortcuts Sounds Time
Touchpad <preference>Tracker VirtualMemory Touchpad <preference>Tracker VirtualMemory
; ;
SYSTEM_DEMOS = BSnow Chart Clock Cortex FontDemo SYSTEM_DEMOS = BSnow Chart Clock Cortex FontDemo
@@ -499,7 +499,7 @@ AddFilesToHaikuImage system add-ons media : $(SYSTEM_ADD_ONS_MEDIA) ;
AddFilesToHaikuImage system add-ons media plugins AddFilesToHaikuImage system add-ons media plugins
: $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ; : $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ;
AddFilesToHaikuImage system add-ons Tracker AddFilesToHaikuImage system add-ons Tracker
: FileType-F Mark\ as\ New-N Mark\ as\ Read-R Open\ Target\ Folder-O OpenTerminal-T ZipOMatic-Z ; : FileType-F Mark\ as Mark\ as\ Read-R Open\ Target\ Folder-O OpenTerminal-T ZipOMatic-Z ;
AddSymlinkToHaikuImage system add-ons Tracker AddSymlinkToHaikuImage system add-ons Tracker
: /boot/system/preferences/Backgrounds : Background-B ; : /boot/system/preferences/Backgrounds : Background-B ;
AddSymlinkToHaikuImage system add-ons Tracker AddSymlinkToHaikuImage system add-ons Tracker
@@ -508,7 +508,7 @@ AddSymlinkToHaikuImage system add-ons Tracker
: /boot/system/apps/DiskUsage : DiskUsage-I ; : /boot/system/apps/DiskUsage : DiskUsage-I ;
AddFilesToHaikuImage system add-ons input_server devices AddFilesToHaikuImage system add-ons input_server devices
: <input>keyboard <input>mouse <input>wacom ; : <input>keyboard <input>mouse <input>wacom ;
AddFilesToHaikuImage system add-ons input_server filters AddFilesToHaikuImage system add-ons input_server filters
: screen_saver shortcut_catcher ; : screen_saver shortcut_catcher ;
AddFilesToHaikuImage system add-ons kernel network AddFilesToHaikuImage system add-ons kernel network
: <net>notifications stack ; : <net>notifications stack ;
+3 -4
View File
@@ -2,11 +2,11 @@ SubDir HAIKU_TOP src add-ons tracker mark_as ;
SetSubDirSupportedPlatformsBeOSCompatible ; SetSubDirSupportedPlatformsBeOSCompatible ;
AddResources Mark\ as\ New-N : MarkAsNew.rdef ; AddResources Mark\ as : MarkAs.rdef ;
AddResources Mark\ as\ Read-R : MarkAsRead.rdef ; AddResources Mark\ as\ Read-R : MarkAsRead.rdef ;
Addon Mark\ as\ New-N : Addon Mark\ as :
MarkAsNew.cpp MarkAs.cpp
: be tracker : be tracker
; ;
@@ -14,4 +14,3 @@ Addon Mark\ as\ Read-R :
MarkAsRead.cpp MarkAsRead.cpp
: be tracker : be tracker
; ;
+105 -17
View File
@@ -1,33 +1,121 @@
/* /*
* Copyright 2006, Ryan Leavengood, [email protected]. All rights reserved. * Copyright 2009, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <Directory.h>
#include <Entry.h> #include <Entry.h>
#include <FindDirectory.h>
#include <MenuItem.h>
#include <Message.h> #include <Message.h>
#include <Node.h> #include <Node.h>
#include <Path.h>
#include <PopUpMenu.h>
#include <String.h> #include <String.h>
#include <TrackerAddOn.h> #include <View.h>
#include <Window.h>
/*! Returns the current mouse position in screen coordinates.
Since there is no method to retrieve this in the Be API without a view,
this looks a bit more complicated.
*/
static BPoint
mouse_position()
{
BWindow* window = new BWindow(BRect(-1000, -1000, -900, -900), "mouse",
B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_AVOID_FRONT | B_AVOID_FOCUS);
BView* view = new BView(window->Bounds(), "mouse", B_FOLLOW_ALL, 0);
window->AddChild(view);
window->Run();
window->Lock();
BPoint position;
uint32 buttons;
view->GetMouse(&position, &buttons);
view->ConvertToScreen(&position);
window->Quit();
return position;
}
static void
add_status_item(BMenu* menu, const char* name)
{
if (menu->FindItem(name) != NULL)
return;
// Sort items alphabetically
int32 index;
for (index = 0; index < menu->CountItems(); index++) {
if (strcmp(menu->ItemAt(index)->Label(), name) > 0)
break;
}
menu->AddItem(new BMenuItem(name, NULL), index);
}
static void
retrieve_status_items(BMenu* menu)
{
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
return;
path.Append("Mail/status");
BDirectory directory(path.Path());
entry_ref ref;
while (directory.GetNextRef(&ref) == B_OK) {
if (!strcmp(ref.name, ".") || !strcmp(ref.name, ".."))
continue;
add_status_item(menu, ref.name);
}
add_status_item(menu, "New");
add_status_item(menu, "Read");
add_status_item(menu, "Replied");
}
// #pragma mark -
extern "C" void extern "C" void
process_refs(entry_ref dir, BMessage* msg, void* /*reserved*/) process_refs(entry_ref dir, BMessage* message, void* /*reserved*/)
{ {
int32 refs; BPopUpMenu* menu = new BPopUpMenu("status");
retrieve_status_items(menu);
BMenuItem* item = menu->Go(mouse_position() - BPoint(5, 5), false, true);
if (item == NULL)
return;
BString status = item->Label();
entry_ref ref; entry_ref ref;
BString status(STATUS_HERE); for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
// The above will be substituted with a real value (such as "New" or
// "Read") by a #define and #include in another file. This is done
// to avoid duplicate code.
BString type;
for (refs = 0; msg->FindRef("refs", refs, &ref) == B_NO_ERROR; refs++) {
BNode node(&ref); BNode node(&ref);
if ((node.InitCheck() == B_NO_ERROR) BString type;
&& (node.ReadAttrString("BEOS:TYPE", &type) == B_NO_ERROR)
&& (type == "text/x-email")) if (node.InitCheck() == B_OK
node.WriteAttrString("MAIL:status", &status); && node.ReadAttrString("BEOS:TYPE", &type) == B_OK
} && type == "text/x-email") {
} BString previousStatus;
// Only update the attribute if there is an actual change
if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
|| previousStatus != status)
node.WriteAttrString("MAIL:status", &status);
}
}
}
@@ -1,8 +1,4 @@
/* resource app_signature "application/x-vnd.Haiku-MarkAs";
* MarkAsNew.rdef
*/
resource app_signature "application/x-vnd.Haiku-MarkAsNew";
resource file_types message { resource file_types message {
"types" = "text/x-email" "types" = "text/x-email"
@@ -19,8 +15,8 @@ resource app_version {
internal = 1, internal = 1,
short_info = "Marks emails as New", short_info = "MarkAs, Copyright 2006-2009 Haiku, Inc.",
long_info = "MarkAsNew, Copyright 2006-2009 Haiku, Inc. A Tracker Add-on which marks the status of emails as New." long_info = "A Tracker Add-on that marks emails with the chosen status."
}; };
resource vector_icon { resource vector_icon {
+35 -2
View File
@@ -1,2 +1,35 @@
#define STATUS_HERE "Read" /*
#include "MarkAs.cpp" * Copyright 2009, Axel Dörfler, [email protected].
* Copyright 2006, Ryan Leavengood, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Entry.h>
#include <Message.h>
#include <Node.h>
#include <String.h>
extern "C" void
process_refs(entry_ref dir, BMessage* message, void* /*reserved*/)
{
entry_ref ref;
for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
BNode node(&ref);
BString type;
if (node.InitCheck() == B_OK
&& node.ReadAttrString("BEOS:TYPE", &type) == B_OK
&& type == "text/x-email") {
BString previousStatus;
BString status("Read");
// Only update the attribute if there is an actual change
if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
|| previousStatus != status)
node.WriteAttrString("MAIL:status", &status);
}
}
}
+2 -6
View File
@@ -1,7 +1,3 @@
/*
* MarkAsRead.rdef
*/
resource app_signature "application/x-vnd.Haiku-MarkAsRead"; resource app_signature "application/x-vnd.Haiku-MarkAsRead";
resource file_types message { resource file_types message {
@@ -19,8 +15,8 @@ resource app_version {
internal = 1, internal = 1,
short_info = "Marks email as Read", short_info = "MarkAsRead, Copyright 2006-2009 Haiku, Inc.",
long_info = "MarkAsRead, Copyright 2006-2009 Haiku, Inc. A Tracker Add-on which marks the status of emails as Read." long_info = "A Tracker Add-on which marks the status of emails as Read."
}; };
resource vector_icon { resource vector_icon {