diff options
author | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2016-02-05 12:32:35 +0100 |
---|---|---|
committer | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2016-02-05 12:32:35 +0100 |
commit | 19cafba037f55fa962e5819950cb1b1f7332180e (patch) | |
tree | 540e7640a31f8d706b582fec759744045620f786 /parrot_zik | |
parent | 0f18e76062340a6beda2142ccaedccad09cd5193 (diff) | |
parent | 4098b681ca9bc4b57e8283f6f21d139fc1c9940b (diff) | |
download | pyParrotZikTCP-19cafba037f55fa962e5819950cb1b1f7332180e.tar.xz pyParrotZikTCP-19cafba037f55fa962e5819950cb1b1f7332180e.zip |
Merge pull request #5 from MGrishkin/gtk_on_linux
Use gtk on linux
Diffstat (limited to '')
-rw-r--r-- | parrot_zik/indicator/__init__.py | 11 | ||||
-rw-r--r-- | parrot_zik/indicator/gtk_wrapping.py | 6 | ||||
-rw-r--r-- | parrot_zik/indicator/linux.py | 49 |
3 files changed, 50 insertions, 16 deletions
diff --git a/parrot_zik/indicator/__init__.py b/parrot_zik/indicator/__init__.py index 4194dde..156f7de 100644 --- a/parrot_zik/indicator/__init__.py +++ b/parrot_zik/indicator/__init__.py @@ -3,10 +3,17 @@ __all__ = ('SysIndicator', 'Menu', 'MenuItem') import sys if sys.platform in ['linux', 'linux2']: - from parrot_zik.indicator.linux import LinuxIndicator as SysIndicator + import argparse + parser = argparse.ArgumentParser() + parser.add_argument("--gtk", action="store_true") + args = parser.parse_args() + if args.gtk: + from parrot_zik.indicator.linux import LinuxGtkIndicator as SysIndicator + else: + from parrot_zik.indicator.linux import LinuxAppIndicator as SysIndicator from parrot_zik.indicator.gtk_wrapping import GTKMenuItem as MenuItem from parrot_zik.indicator.gtk_wrapping import GTKMenu as Menu -elif sys.platform == 'win32': +elif sys.platform in ['win32']: from parrot_zik.indicator.windows import WindowsIndicator as SysIndicator from parrot_zik.indicator.gtk_wrapping import GTKMenuItem as MenuItem from parrot_zik.indicator.gtk_wrapping import GTKMenu as Menu diff --git a/parrot_zik/indicator/gtk_wrapping.py b/parrot_zik/indicator/gtk_wrapping.py index ce78c1d..6d4a5a8 100644 --- a/parrot_zik/indicator/gtk_wrapping.py +++ b/parrot_zik/indicator/gtk_wrapping.py @@ -13,6 +13,12 @@ class GTKMenu(object): def reposition(self): self.gtk_menu.reposition() + def popup(self, *args, **kwargs): + self.gtk_menu.popup(*args, **kwargs) + + def poVpdown(self, *args, **kwargs): + pass + class GTKMenuItem(MenuItemBase): def __init__(self, name, action, sensitive=True, checkitem=False, visible=True): diff --git a/parrot_zik/indicator/linux.py b/parrot_zik/indicator/linux.py index 278f781..f6f9cfc 100644 --- a/parrot_zik/indicator/linux.py +++ b/parrot_zik/indicator/linux.py @@ -6,17 +6,7 @@ from parrot_zik.indicator.base import BaseIndicator class LinuxIndicator(BaseIndicator): - def __init__(self, icon, menu): - import appindicator - self.icon_directory = os.path.join('/', 'usr', 'share', 'icons', 'zik') - if not os.path.isdir(self.icon_directory): - self.icon_directory = os.path.join('share', 'icons', 'zik') - statusicon = appindicator.Indicator( - "new-parrotzik-indicator", "indicator-messages", - appindicator.CATEGORY_APPLICATION_STATUS) - statusicon.set_status(appindicator.STATUS_ACTIVE) - statusicon.set_icon_theme_path(self.icon_directory) - statusicon.set_menu(menu.gtk_menu) + def __init__(self, icon, menu, statusicon): super(LinuxIndicator, self).__init__(icon, menu, statusicon) def gtk_right_click_event(self, icon, button, time): @@ -28,9 +18,6 @@ class LinuxIndicator(BaseIndicator): self.menu_shown = False self.menu.poVpdown() - def setIcon(self, name): - self.statusicon.set_icon(name) - @classmethod def main(cls): gtk.main() @@ -46,3 +33,37 @@ class LinuxIndicator(BaseIndicator): about_dialog.set_authors(["Dmitry Moiseev m0sia@m0sia.ru"]) about_dialog.run() about_dialog.destroy() + + +class LinuxAppIndicator(LinuxIndicator): + def __init__(self, icon, menu): + import appindicator + self.icon_directory = os.path.join('/', 'usr', 'share', 'icons', 'zik') + if not os.path.isdir(self.icon_directory): + self.icon_directory = os.path.join('share', 'icons', 'zik') + statusicon = appindicator.Indicator( + "new-parrotzik-indicator", "indicator-messages", + appindicator.CATEGORY_APPLICATION_STATUS) + statusicon.set_status(appindicator.STATUS_ACTIVE) + statusicon.set_icon_theme_path(self.icon_directory) + statusicon.set_menu(menu.gtk_menu) + super(LinuxIndicator, self).__init__(icon, menu, statusicon) + + def setIcon(self, name): + self.statusicon.set_icon(name) + + + +class LinuxGtkIndicator(LinuxIndicator): + def __init__(self, icon, menu): + self.icon_directory = os.path.join( + '/usr', 'share', 'icons/') + self.menu_shown = False + statusicon = gtk.StatusIcon() + statusicon.connect("popup-menu", self.gtk_right_click_event) + statusicon.set_tooltip("Parrot Zik") + super(LinuxIndicator, self).__init__(icon, menu, statusicon) + + def setIcon(self, name): + self.statusicon.set_from_file(self.icon_directory + name + '.png') + |