Skip to content

Commit

Permalink
Creating desktop file
Browse files Browse the repository at this point in the history
  • Loading branch information
codywd committed Oct 24, 2014
1 parent 21bbcc3 commit ffb5b2e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 43 deletions.
11 changes: 6 additions & 5 deletions netgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def __init__(self):
self.APindex = 0
self.p = None
self.builder = Gtk.Builder()
GObject.type_register(GtkSource.View)
self.builder.add_from_file(program_loc + "UI.glade")
self.dialog = self.builder.get_object("passwordDialog")
self.ap_list = self.builder.get_object("treeview1")
self.ap_store = Gtk.ListStore(str, str, str, str)
Expand All @@ -115,8 +117,6 @@ def init_ui(self):
is_connected()
# Create a "Builder", which basically allows me to import the Glade file for a complete interface.
# I love Glade, btw. So much quicker than manually coding everything.
GObject.type_register(GtkSource.View)
self.builder.add_from_file(program_loc + "UI.glade")

# Grab the "window1" attribute from UI.glade, and set it to show everything.
window = self.builder.get_object("mainWindow")
Expand Down Expand Up @@ -211,11 +211,12 @@ def init_ui(self):
window.show_all()

def open_editor(self, e):
open(status_dir + "profile_to_edit", 'w').close()
select = self.ap_list.get_selection()
if select == "" or None:
network_ssid = self.get_ssid(select)
if network_ssid is None:
profileEditor.NetGUIProfileEditor()
else:
network_ssid = self.get_ssid(select)
profile = "/etc/netctl/netgui_" + network_ssid
d = open(status_dir + "profile_to_edit", 'w')
d.write(profile)
Expand Down Expand Up @@ -452,7 +453,7 @@ def get_network_pw(self):
password = entry.get_text()
return password

@staticmethod

def get_ssid(self, selection):
model, treeiter = selection.get_selected()
if treeiter is not None:
Expand Down
77 changes: 40 additions & 37 deletions profileEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
from gi.repository import Notify

# Import Personal Files
import netgui

try:
d = open(status_dir + "profile_to_edit", 'r')
profile_to_edit = d.readline()
if profile_to_edit != "":
print(profile_to_edit)
if profile_to_edit != None:
if profile_to_edit is not None:
print(profile_to_edit)
profile_to_edit = profile_to_edit
else:
Expand All @@ -47,62 +46,66 @@ def __init__(self):
self.APindex = 0
self.p = None
self.builder = Gtk.Builder()
self.InitUI()
self.init_ui()

def InitUI(self):
def init_ui(self):
# Create a "Builder", which basically allows me to import the Glade file for a complete interface.
# I love Glade, btw. So much quicker than manually coding everything.
GObject.type_register(GtkSource.View)
self.builder.add_from_file(program_loc + "UI.glade")

go = self.builder.get_object
profileEditor = go("profileEditor")
menuProfExit = go("exitProfWin")
saveBtn = go("saveMenuProf")
saveToolBtn = go("saveToolBtn")
openToolBtn = go("openToolBtn")
clearBtn = go("clearToolBtn")
attributesBtn = go("attributesToolBtn")
exitProfBtn = go("exitToolBtn")
profile_editor = go("profileEditor")
menu_prof_exit = go("exitProfWin")
save_button = go("saveMenuProf")
save_tool_button = go("saveToolBtn")
open_tool_button = go("openToolBtn")
clear_button = go("clearToolBtn")
attributes_button = go("attributesToolBtn")
exit_profile_button = go("exitToolBtn")
self.netctlEditor = go("profileEditorView")
self.buffer = go("textbuffer1")

# Connecting the "clicked" signals of each button to the relevant function.
saveBtn.connect("activate", self.saveClicked)
saveToolBtn.connect("clicked", self.saveClicked)
attributesBtn.connect("clicked", self.attributesClicked)
clearBtn.connect("clicked", self.clearClicked)
profileEditor.connect("show", self.OnLoad)
exitProfBtn.connect("clicked", self.exitProfClicked)
menuProfExit.connect("activate", self.exitProfClicked)
openToolBtn.connect("clicked", self.openClicked)
save_button.connect("activate", self.save_clicked)
save_tool_button.connect("clicked", self.save_clicked)
attributes_button.connect("clicked", self.attributes_clicked)
clear_button.connect("clicked", self.clear_clicked)
profile_editor.connect("show", self.on_load)
exit_profile_button.connect("clicked", self.exit_prof_clicked)
menu_prof_exit.connect("activate", self.exit_prof_clicked)
open_tool_button.connect("clicked", self.open_clicked)
# Opening the Prefereces Dialog.
profileEditor.show_all()
profile_editor.show_all()

def openClicked(self, e):
def open_clicked(self, e):
pass

def saveClicked(self, e):
def save_clicked(self, e):
pass

def attributesClicked(self, e):
def attributes_clicked(self, e):
pass

def clearClicked(self, e):
def clear_clicked(self, e):
pass

def OnLoad(self, e):
try:
txt=open(profile_to_edit).read()
except:
return False
self.buffer.set_text(txt)
self.buffer.set_data('filename', profile_to_edit)
self.buffer.set_modified(False)
self.buffer.place_cursor(self.buffer.get_start_iter())
return True

def exitProfClicked(self, e):
def on_load(self, e):
if profile_to_edit is None:
pass
else:
try:
txt=open(profile_to_edit).read()
except:
return False
self.buffer.set_text(txt)
self.buffer.set_data('filename', profile_to_edit)
self.buffer.set_modified(False)
self.buffer.place_cursor(self.buffer.get_start_iter())
return True

@staticmethod
def exit_prof_clicked(self, e):
sys.exit()


Expand Down
8 changes: 8 additions & 0 deletions scripts/netgui.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=NetGUI
Comment=A Grapical Frontend for NetCTL
Exec=su -c "netgui"
Icon=/usr/share/netgui/imgs/logo.png
Terminal=false
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
'imgs/aboutLogo.png',
'imgs/disconnect.png',
'imgs/logo.png',
'imgs/preferences.png'])]
'imgs/preferences.png']),
('~/.local/applications',
['scripts/netgui.desktop'])
]
)

0 comments on commit ffb5b2e

Please sign in to comment.