Commit 9181df75 authored by Thomas Bechtold's avatar Thomas Bechtold

Merge branch 'cmdline' into 'master'

A few improvements & --address=ADDRESS support

See merge request !25
parents 54bdef31 b14c9265
Pipeline #170248 passed with stages
in 2 minutes and 40 seconds
Welcome to D-Feet (https://wiki.gnome.org/Apps/DFeet)
Requirements:
python >= 2.7
python-gi >= 3.3.91
gtk >= 3.6
Optional Requriements:
gnome-python-libwnck - for displaying application icons next to the application
To run localy for testing, install it using the prefix option:
meson --prefix=/tmp/d-feet && ninja -C _build install
And then execute it:
/tmp/d-feet/bin/d-feet
To install in the system:
meson _build && ninja -C _build install
# Welcome to [D-Feet](https://wiki.gnome.org/Apps/DFeet)
Requirements:
- python >= 2.7
- python-gi >= 3.3.91
- gtk >= 3.6
Optional Requirements:
- gnome-python-libwnck - for displaying application icons next to the application
To run localy for testing, install it using the prefix option:
meson --prefix=/tmp/d-feet _build && ninja -C _build install
And then execute it:
/tmp/d-feet/bin/d-feet
To install in the system:
meson _build && ninja -C _build install
# -*- coding: utf-8 -*-
from __future__ import print_function
from gi.repository import Gtk, Gio, GObject, Gdk
from gi.repository import Gtk, Gio, GObject, Gdk, GLib
from dfeet.window import DFeetWindow
import gettext
import os
......@@ -9,6 +9,20 @@ import os
_ = gettext.gettext
def make_option(long_name, short_name=None, flags=0, arg=GLib.OptionArg.NONE,
arg_data=None, description=None, arg_description=None):
# surely something like this should exist inside PyGObject itself?!
option = GLib.OptionEntry()
option.long_name = long_name.lstrip('-')
option.short_name = 0 if not short_name else short_name.lstrip('-')
option.flags = flags
option.arg = arg
option.arg_data = arg_data
option.description = description
option.arg_description = arg_description
return option
class DFeetApp(Gtk.Application):
def __init__(self, package, version, data_dir):
......@@ -17,10 +31,26 @@ class DFeetApp(Gtk.Application):
self.data_dir = data_dir
Gtk.Application.__init__(self, application_id="org.gnome.dfeet",
flags=Gio.ApplicationFlags.FLAGS_NONE)
self.add_main_option_entries([
make_option("--version", description=_("Show version number and exit")),
make_option("--address", arg=GLib.OptionArg.STRING, arg_description="ADDRESS",
description=_("Open the specified bus address")),
])
def do_handle_local_options(self, options):
self.options = options
if options.contains("version"):
print(_("D-Feet version: {}").format(self.version))
return 0
return -1
# Note that the function in C activate() becomes do_activate() in Python
def do_activate(self):
self._main_win = DFeetWindow(self, self.version, self.data_dir)
if self.options.contains("address"):
address = self.options.lookup_value("address").get_string()
if not self._main_win.connect_to(address):
self.quit()
# Note that the function in C startup() becomes do_startup() in Python
def do_startup(self):
......
......@@ -16,4 +16,5 @@ df_data = files(
python.install_sources(
df_data,
subdir: 'dfeet',
pure: true,
)
......@@ -147,6 +147,24 @@ class DFeetWindow(Gtk.ApplicationWindow):
except Exception as e:
print(e)
def connect_to(self, address):
"""connect to given bus address"""
try:
bw = BusWatch(self.data_dir, address)
self.stack.add_titled(bw.box_bus, address, address)
self.stack.set_visible_child_name(address)
# Fill history
if address in self.bus_history:
self.bus_history.remove(address)
self.bus_history.insert(0, address)
# Truncating history
if (len(self.bus_history) > self.HISTORY_MAX_SIZE):
self.bus_history = self.bus_history[0:self.HISTORY_MAX_SIZE]
except Exception as e:
print("can not connect to '%s': %s" % (address, str(e)))
return False
return True
def __action_connect_other_bus_cb(self, action, parameter):
"""connect to other bus"""
dialog = AddConnectionDialog(self.data_dir, self, self.bus_history)
......@@ -160,18 +178,7 @@ class DFeetWindow(Gtk.ApplicationWindow):
self.activate_action('connect-system-bus', None)
return
else:
try:
bw = BusWatch(self.data_dir, address)
self.stack.add_titled(bw.box_bus, address, address)
# Fill history
if address in self.bus_history:
self.bus_history.remove(address)
self.bus_history.insert(0, address)
# Truncating history
if (len(self.bus_history) > self.HISTORY_MAX_SIZE):
self.bus_history = self.bus_history[0:self.HISTORY_MAX_SIZE]
except Exception as e:
print("can not connect to '%s': %s" % (address, str(e)))
self.connect_to(address)
dialog.destroy()
def __action_close_bus_cb(self, action, parameter):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment