Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tractor
carburetor
Commits
67f19b3d
Commit
67f19b3d
authored
Nov 28, 2018
by
Danial Behzadi
Browse files
sidebar completed
parent
4175c2ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
carburetor
View file @
67f19b3d
...
...
@@ -14,15 +14,17 @@ from subprocess import PIPE, Popen
from
sys
import
exit
from
threading
import
Thread
command
=
"tractor "
#command = "tractor "
command
=
"/home/danialbehzadi/Documents/Sources/tractor/tractor "
dconf
=
Gio
.
Settings
.
new
(
"org.tractor"
)
try
:
localedir
=
[
skel_path
for
skel_path
in
GLib
.
get_system_data_dirs
()
if
os
.
path
.
exists
(
skel_path
)
and
"carburetor"
in
os
.
listdir
(
skel_path
)][
-
1
]
+
"/carburetor/locales"
translate
=
gettext
.
translation
(
'messages'
,
localedir
=
localedir
,
fallback
=
True
)
_
=
translate
.
gettext
except
IndexError
:
print
(
"There is a problem with your packaging. Report it to package maintainer."
)
s_data_dir
=
[
skel_path
for
skel_path
in
GLib
.
get_system_data_dirs
()
if
os
.
path
.
exists
(
skel_path
)
and
"carburetor"
in
os
.
listdir
(
skel_path
)][
-
1
]
+
"/carburetor"
except
IndexError
as
e
:
print
(
"There is a problem with your packaging. Report it to the package maintainer: "
,
e
)
exit
(
1
)
locale_dir
=
s_data_dir
+
"/locales"
translate
=
gettext
.
translation
(
'messages'
,
localedir
=
locale_dir
,
fallback
=
True
)
_
=
translate
.
gettext
app_name
=
_
(
"Carburetor"
)
notify2
.
init
(
app_name
)
...
...
@@ -310,7 +312,6 @@ class BridgeConfig(Gtk.Box):
self
.
pack_start
(
vbox
,
False
,
True
,
0
)
class
BridgeList
(
Gtk
.
Box
):
config_dir
=
GLib
.
get_user_config_dir
()
+
"/tractor"
def
__init__
(
self
):
Gtk
.
Box
.
__init__
(
self
)
self
.
set_homogeneous
(
False
)
...
...
@@ -323,17 +324,13 @@ class BridgeList(Gtk.Box):
self
.
pack_start
(
vbox
,
False
,
False
,
0
)
scrolled_window
=
Gtk
.
ScrolledWindow
()
s
crolled_window
.
set_min_content_height
(
150
)
s
elf
.
get_style_context
().
add_class
(
"bridgeslist"
)
text_view
=
Gtk
.
TextView
()
text_view
.
set_wrap_mode
(
1
)
text_buffer
=
text_view
.
get_buffer
()
bridges_file
=
self
.
config_dir
+
"/Bridges"
if
not
os
.
path
.
isfile
(
bridges_file
):
try
:
bridges_file
=
[
skel_path
for
skel_path
in
GLib
.
get_system_data_dirs
()
if
os
.
path
.
exists
(
skel_path
)
and
"tractor"
in
os
.
listdir
(
skel_path
)][
-
1
]
+
"/tractor/SampleBridges"
except
IndexError
:
print
(
"There is a problem with your packaging. Report it to package maintainer."
)
exit
(
1
)
get_bridges
=
Popen
(
command
+
"bridgesfile"
,
stdout
=
PIPE
,
shell
=
True
)
bridges
=
get_bridges
.
stdout
.
read
()
bridges_file
=
bridges
.
decode
(
"utf-8"
).
strip
(
'
\n
'
)
with
open
(
bridges_file
)
as
file
:
text
=
file
.
read
()
text_buffer
.
set_text
(
str
(
text
))
...
...
@@ -344,17 +341,14 @@ class BridgeList(Gtk.Box):
vbox
.
set_homogeneous
(
False
)
button
=
Gtk
.
Button
()
button
.
set_label
(
_
(
"Save"
))
button
.
connect
(
"clicked"
,
self
.
on_save_clicked
,
text_buffer
)
button
.
connect
(
"clicked"
,
self
.
on_save_clicked
,
text_buffer
,
bridges_file
)
vbox
.
pack_start
(
button
,
False
,
False
,
0
)
self
.
pack_start
(
vbox
,
False
,
False
,
0
)
def
on_save_clicked
(
self
,
button
,
text_buffer
):
bridges_file
=
self
.
config_dir
+
"/Bridges"
def
on_save_clicked
(
self
,
button
,
text_buffer
,
bridges_file
):
text
=
text_buffer
.
get_text
(
text_buffer
.
get_start_iter
(),
text_buffer
.
get_end_iter
(),
0
)
bridge_regex
=
re
.
compile
(
r
'^( )*([Bb][Rr][Ii][Dd][Gg][Ee])?( )*'
,
re
.
MULTILINE
)
if
text
==
bridge_regex
.
sub
(
'Bridge '
,
text
):
if
not
os
.
path
.
exists
(
self
.
config_dir
):
os
.
makedirs
(
self
.
config_dir
)
with
open
(
bridges_file
,
'w'
)
as
file
:
file
.
write
(
text
)
else
:
...
...
@@ -400,33 +394,38 @@ class ObfsPath (Gtk.Box):
class
MainContainer
(
Gtk
.
Box
):
def
__init__
(
self
):
Gtk
.
Box
.
__init__
(
self
)
self
.
get_style_context
().
add_class
(
"maincontainer"
)
side_bar
=
Gtk
.
ListBox
()
side_bar
.
connect
(
"row_selected"
,
self
.
on_row_selected
)
side_bar
.
set_header_func
(
self
.
sidebar_separators
)
listbox_row_general
=
ListBoxRowGeneral
()
general
=
_
(
"General"
)
ports
=
_
(
"Ports"
)
bridges
=
_
(
"Bridges"
)
listbox_row_general
=
ListBoxRow
(
general
)
side_bar
.
add
(
listbox_row_general
)
listbox_row_ports
=
ListBoxRow
P
orts
(
)
listbox_row_ports
=
ListBoxRow
(
p
orts
)
side_bar
.
add
(
listbox_row_ports
)
listbox_row_bridges
=
ListBoxRow
B
ridges
(
)
listbox_row_bridges
=
ListBoxRow
(
b
ridges
)
side_bar
.
add
(
listbox_row_bridges
)
scrolled_window
=
Gtk
.
ScrolledWindow
()
scrolled_window
.
add
(
side_bar
)
scrolled_window
.
props
.
hscrollbar_policy
=
Gtk
.
PolicyType
.
NEVER
self
.
pack_start
(
scrolled_window
,
True
,
Tru
e
,
0
)
self
.
pack_start
(
scrolled_window
,
False
,
Fals
e
,
0
)
separator
=
Gtk
.
Separator
(
orientation
=
Gtk
.
Orientation
.
VERTICAL
)
self
.
pack_start
(
separator
,
False
,
False
,
0
)
self
.
main_content
=
Gtk
.
Stack
()
stack_general
=
StackGeneral
()
self
.
main_content
.
add_named
(
stack_general
,
_
(
"G
eneral
"
)
)
stack_ports
=
StackPorts
()
self
.
main_content
.
add_named
(
stack_ports
,
_
(
"P
orts
"
)
)
self
.
main_content
.
add_named
(
stack_general
,
g
eneral
)
stack_ports
=
StackPorts
()
self
.
main_content
.
add_named
(
stack_ports
,
p
orts
)
stack_bridges
=
StackBridges
()
self
.
main_content
.
add_named
(
stack_bridges
,
_
(
"B
ridges
"
)
)
self
.
main_content
.
add_named
(
stack_bridges
,
b
ridges
)
self
.
pack_start
(
self
.
main_content
,
True
,
True
,
0
)
def
on_row_selected
(
self
,
box
,
row
):
...
...
@@ -442,27 +441,11 @@ class MainContainer(Gtk.Box):
class
ListBoxRow
(
Gtk
.
ListBoxRow
):
def
__init__
(
self
):
def
__init__
(
self
,
name
):
Gtk
.
ListBoxRow
.
__init__
(
self
)
self
.
props
.
halign
=
Gtk
.
Align
.
START
self
.
get_style_context
().
add_class
(
"listboxrow"
)
class
ListBoxRowGeneral
(
ListBoxRow
):
def
__init__
(
self
):
ListBoxRow
.
__init__
(
self
)
label
=
Gtk
.
Label
(
_
(
"General"
))
self
.
add
(
label
)
class
ListBoxRowPorts
(
ListBoxRow
):
def
__init__
(
self
):
ListBoxRow
.
__init__
(
self
)
label
=
Gtk
.
Label
(
_
(
"Ports"
))
self
.
add
(
label
)
class
ListBoxRowBridges
(
ListBoxRow
):
def
__init__
(
self
):
ListBoxRow
.
__init__
(
self
)
label
=
Gtk
.
Label
(
_
(
"Bridges"
))
label
=
Gtk
.
Label
(
name
)
label
.
props
.
xalign
=
0.0
self
.
add
(
label
)
class
StackGeneral
(
Gtk
.
ScrolledWindow
):
...
...
@@ -505,14 +488,15 @@ class Window(Gtk.ApplicationWindow):
def
__init__
(
self
):
Gtk
.
ApplicationWindow
.
__init__
(
self
)
self
.
set_size_request
(
600
,
400
)
self
.
set_icon_name
(
"carburetor"
)
self
.
load_css
()
def
load_css
(
self
):
css_provider
=
Gtk
.
CssProvider
()
#TODO: fix it for packaging
css_provider
.
load_from_path
(
'style.css'
)
try
:
css_provider
.
load_from_path
(
s_data_dir
+
'/style.css'
)
except
gi
.
repository
.
GLib
.
Error
as
e
:
print
(
"Can't load css file. This means there is a problem with your packaging. Report it to the package maintainer: "
,
e
)
screen
=
Gdk
.
Screen
.
get_default
()
context
=
Gtk
.
StyleContext
()
context
.
add_provider_for_screen
(
screen
,
css_provider
,
Gtk
.
STYLE_PROVIDER_PRIORITY_USER
)
...
...
debian/changelog
View file @
67f19b3d
carburetor (2.5-1) bionic; urgency=medium
* Use sidebar design
* copy bridges file via tractor
-- Danial Behzadi <dani.behzi@ubuntu.com> Wed, 28 Nov 2018 16:45:00 +0330
carburetor (2.4-1) bionic; urgency=medium
* Use threading for Popens
...
...
debian/install
View file @
67f19b3d
carburetor /usr/bin
desktop/carburetor.desktop /usr/share/applications
desktop/carburetor.svg /usr/share/icons/hicolor/scalable/apps
desktop/style.css /usr/share/carburetor
locales /usr/share/carburetor
desktop/style.css
0 → 100644
View file @
67f19b3d
stack
box
{
margin
:
0.2em
;
}
.listboxrow
{
padding
:
0.7em
;
min-width
:
10em
;
}
.maincontainer
{
min-width
:
45em
;
min-height
:
25em
;
}
.bridgeslist
{
min-height
:
15em
;
}
style.css
deleted
100644 → 0
View file @
4175c2ba
stack
box
{
margin
:
0.2em
;
}
.listboxrow
{
padding
:
0.5em
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment