Files
haiku-beta6/src/apps/autoraise/settings.h
T
Kyle Ambroff-Kao 107712bf01 AutoRaise: Properly load tray icon bitmap
AutoRaise needs to load bitmaps stored as resources in the AppRaise
image. The strategy it used before was to store the path to itself in
its settings file.

It stored the entry_ref to the image in the settings, which may not be
stable across reboots with packagefs. In addition, the path could
change at some point for any other reason.

This patch changes AutoRaise to just use the same method as other tray
applets, which is to search the process for the image containing the
AutoRaise code, and then to get the path from the image_info.

Most of the initialization work is performed by TrayView::_init(),
which is called by the constructor. Some of the operations performed
by this method can fail, leaving TrayView partially initialized. Any
error is handled by returning early after telling Deskbar to remove
this item so that it will not continue running in a partially
initialized state. Deskbar will invoke the destructor so even a
partially initialized TrayView will be cleaned up.

Fixes #16473

Change-Id: Id1ac1ef78d410a7d191cfe88f1ba1db30e258adc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3341
Reviewed-by: Jérôme Duval <[email protected]>
2020-10-22 17:52:53 +00:00

63 lines
1.3 KiB
C++

#ifndef SETTINGS_H
#define SETTINGS_H
/***************************************************
settings.h
Mechanisms for managing the settings setting/retireval for AutoRaise
2002 mmu_man
from Deskscope:
2000 Shamyl Zakariya
***************************************************/
#include "common.h"
/****************************************
AutoRaiseSettings
Simple class for getting and setting prefs.
Instantiating will open up settings file
Destroying will write settings plus any changes
back into the file.
Settings file won't be updated until AutoRaiseSettings
destructor is called. Doens't matter if it's allocated off
heap or stack. I recommend stack, though, to keep likelyhood
of race conditions down.
File is defined in common.h as SETTINGS_FILE
****************************************/
// make adding configuration fields easier
#define CONF_ADDPROP(_type, _name) \
protected:\
_type _conf##_name;\
public:\
void Set##_name(_type value);\
_type _name();
class AutoRaiseSettings
{
protected:
BFile _settingsFile;
BMessage _settingsMessage;
BMessage openSettingsFile();
void closeSettingsFile();
public:
AutoRaiseSettings();
~AutoRaiseSettings();
CONF_ADDPROP(bool, Active)
CONF_ADDPROP(bigtime_t, Delay)
CONF_ADDPROP(int32, Mode)
};
#undef CONF_ADDPROP
#endif