1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# Copyright (C) 2010 Артём Попов <artfwo@gmail.com>
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License version 3, as published
6
# by the Free Software Foundation.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranties of
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
# PURPOSE. See the GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License along
14
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""Helpers for an Ubuntu application."""
22
from indicator_cpufreq.indicator_cpufreqconfig import get_data_file
25
from gettext import gettext as _
26
gettext.textdomain('indicator-cpufreq')
28
def get_builder(builder_file_name):
29
"""Return a fully-instantiated gtk.Builder instance from specified ui
32
:param builder_file_name: The name of the builder file, without extension.
33
Assumed to be in the 'ui' directory under the data path.
35
# Look for the ui file that describes the user interface.
36
ui_filename = get_data_file('ui', '%s.ui' % (builder_file_name,))
37
if not os.path.exists(ui_filename):
40
builder = gtk.Builder()
41
builder.set_translation_domain('indicator-cpufreq')
42
builder.add_from_file(ui_filename)
46
# Owais Lone : To get quick access to icons and stuff.
47
def get_media_file(media_file_name):
48
media_filename = get_data_file('media', '%s' % (media_file_name,))
49
if not os.path.exists(media_filename):
52
return "file:///"+media_filename
56
"""Support for command line options"""
59
parser = optparse.OptionParser(version="%prog %ver")
61
"-v", "--verbose", action="store_true", dest="verbose",
62
help=_("Show debug messages"))
63
(options, args) = parser.parse_args()
65
# Set the logging level to show debug messages.
67
logging.basicConfig(level=logging.DEBUG)
68
logging.debug('logging enabled')
70
def get_help_uri(page=None):
71
# help_uri from source tree - default language
72
here = os.path.dirname(__file__)
73
help_uri = os.path.abspath(os.path.join(here, '..', 'help', 'C'))
75
if not os.path.exists(help_uri):
76
# installed so use gnome help tree - user's language
77
help_uri = 'indicator-cpufreq'
79
# unspecified page is the index.page
81
help_uri = '%s#%s' % (help_uri, page)
85
def show_uri(parent, link):
86
screen = parent.get_screen()
87
gtk.show_uri(screen, link, gtk.get_current_event_time())