Exemple #1
0
def install_desktop_file():
    desktop_tpl = get_data_path('desktop_file.tpl')
    prefs_tpl = get_data_path('preferences_desktop_file.tpl')

    if os.path.exists(DESKTOP_FILE_PATH):
        print(_('File "%s" already exists.' % DESKTOP_FILE_PATH))
    else:
        print(_('Creating "%s".' % DESKTOP_FILE_PATH))
        with open(desktop_tpl, encoding='utf-8') as tpl_file:
            contents = tpl_file.read()
            contents = contents.replace('{APP_VERSION}', str(version.APP_VERSION))
            contents = contents.replace('{APP_NAME}', version.APP_NAME)
            contents = contents.replace('{COMMENT}', version.APP_DESCRIPTION)
            contents = contents.replace('{EXEC}', 'draobpilc')
            contents = contents.replace('{ICON}', common.ICON_PATH)

            with open(DESKTOP_FILE_PATH, 'w', encoding='utf-8') as desktop_file:
                desktop_file.write(contents)

    if os.path.exists(DESKTOP_PREFS_FILE_PATH):
        print(_('File "%s" already exists.' % DESKTOP_PREFS_FILE_PATH))
    else:
        print(_('Creating "%s".' % DESKTOP_PREFS_FILE_PATH))
        with open(prefs_tpl, encoding='utf-8') as tpl_file:
            contents = tpl_file.read()
            contents = contents.replace('{APP_VERSION}', str(version.APP_VERSION))
            contents = contents.replace('{APP_NAME}', version.APP_NAME)
            contents = contents.replace('{COMMENT}', version.APP_DESCRIPTION)
            contents = contents.replace('{EXEC}', 'draobpilc --preferences')
            contents = contents.replace('{ICON}', common.ICON_PATH)

            with open(DESKTOP_PREFS_FILE_PATH, 'w', encoding='utf-8') as desktop_file:
                desktop_file.write(contents)

    return True
Exemple #2
0
def notify(summary=APP_NAME,
           body=None,
           timeout=Notify.EXPIRES_DEFAULT,
           urgency=Notify.Urgency.NORMAL,
           icon_name_or_path=get_data_path('draobpilc.png'),
           actions=None):
    notification = Notify.Notification.new(summary, body, icon_name_or_path)
    notification.set_timeout(timeout)
    notification.set_urgency(urgency)

    if isinstance(actions, list):
        for action in actions:
            if not isinstance(action, NotifyAction): continue

            notification.add_action(action.id_, action.label, action.callback,
                                    action.user_data)

    notification.show()
    return notification
Exemple #3
0
def notify(
    summary=APP_NAME,
    body=None,
    timeout=Notify.EXPIRES_DEFAULT,
    urgency=Notify.Urgency.NORMAL,
    icon_name_or_path=get_data_path("draobpilc.png"),
    actions=None,
):
    notification = Notify.Notification.new(summary, body, icon_name_or_path)
    notification.set_timeout(timeout)
    notification.set_urgency(urgency)

    if isinstance(actions, list):
        for action in actions:
            if not isinstance(action, NotifyAction):
                continue

            notification.add_action(action.id_, action.label, action.callback, action.user_data)

    notification.show()
    return notification
Exemple #4
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from draobpilc import get_data_path
from draobpilc import version
from draobpilc.lib import utils

APPLICATION = None

SETTINGS_SCHEMA_ID = version.APP_ID
SETTINGS_SCHEMA_DIR = get_data_path('schemas')
SETTINGS = utils.get_settings(
    SETTINGS_SCHEMA_ID,
    SETTINGS_SCHEMA_DIR
)

ICON_PATH = get_data_path('draobpilc.png')
CSS_PATH = get_data_path('style.css')

# settings keys
WIDTH_PERCENTS = 'width-percents'
PROCESSOR_WIDTH_PERCENTS = 'processor-width-percents'
PROCESSOR_HEIGHT_PERCENTS = 'processor-height-percents'
ITEM_MAX_LINES = 'item-max-lines'
ITEM_MAX_HEIGHT = 'item-max-height'
KIND_INDICATOR_WIDTH = 'kind-indicator-width'