Merge two functions in one

merge-requests/64/head
Huluti 2016-12-11 00:58:59 +01:00
parent 29b6fe4d8c
commit 4d10dc2399
2 changed files with 53 additions and 58 deletions

View File

@ -97,7 +97,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="welcomelabel"> <object class="GtkLabel" id="welcometitle">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Welcome to Manjaro!</property> <property name="label" translatable="yes">Welcome to Manjaro!</property>
@ -113,7 +113,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="welcometext"> <object class="GtkLabel" id="welcomelabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -131,7 +131,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="documentationtitle"> <object class="GtkLabel" id="firstcategory">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">DOCUMENTATION</property> <property name="label" translatable="yes">DOCUMENTATION</property>
@ -145,7 +145,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="supporttitle"> <object class="GtkLabel" id="secondcategory">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">SUPPORT</property> <property name="label" translatable="yes">SUPPORT</property>
@ -159,7 +159,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="projecttitle"> <object class="GtkLabel" id="thirdcategory">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">PROJECT</property> <property name="label" translatable="yes">PROJECT</property>
@ -173,9 +173,9 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="readmebtn"> <object class="GtkButton" id="readme">
<property name="label" translatable="yes">Read me</property> <property name="label" translatable="yes">Read me</property>
<property name="name">readmebtn</property> <property name="name">readme</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
@ -187,9 +187,9 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="releasebtn"> <object class="GtkButton" id="release">
<property name="label" translatable="yes">Release info</property> <property name="label" translatable="yes">Release info</property>
<property name="name">releasebtn</property> <property name="name">release</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
@ -201,13 +201,13 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="wikibtn"> <object class="GtkButton" id="wiki">
<property name="label" translatable="yes">Wiki</property> <property name="label" translatable="yes">Wiki</property>
<property name="name">wikibtn</property> <property name="name">wiki</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<signal name="clicked" handler="on_link_btn_clicked" swapped="no"/> <signal name="clicked" handler="on_link_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -215,9 +215,9 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="involvedbtn"> <object class="GtkButton" id="involved">
<property name="label" translatable="yes">Get involved</property> <property name="label" translatable="yes">Get involved</property>
<property name="name">involvedbtn</property> <property name="name">involved</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
@ -229,13 +229,13 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="forumsbtn"> <object class="GtkButton" id="forums">
<property name="label" translatable="yes">Forums</property> <property name="label" translatable="yes">Forums</property>
<property name="name">forumsbtn</property> <property name="name">forums</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="on_link_btn_clicked" swapped="no"/> <signal name="clicked" handler="on_link_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -243,13 +243,13 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="chatbtn"> <object class="GtkButton" id="chat">
<property name="label" translatable="yes">Chat room</property> <property name="label" translatable="yes">Chat room</property>
<property name="name">chatbtn</property> <property name="name">chat</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="on_link_btn_clicked" swapped="no"/> <signal name="clicked" handler="on_link_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -257,13 +257,13 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="maillingbtn"> <object class="GtkButton" id="mailling">
<property name="label" translatable="yes">Mailling lists</property> <property name="label" translatable="yes">Mailling lists</property>
<property name="name">maillingbtn</property> <property name="name">mailling</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="on_link_btn_clicked" swapped="no"/> <signal name="clicked" handler="on_link_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -271,13 +271,13 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="buildbtn"> <object class="GtkButton" id="build">
<property name="label" translatable="yes">Build Manjaro</property> <property name="label" translatable="yes">Build Manjaro</property>
<property name="name">buildbtn</property> <property name="name">build</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="on_link_btn_clicked" swapped="no"/> <signal name="clicked" handler="on_link_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@ -285,13 +285,13 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="donatebtn"> <object class="GtkButton" id="donate">
<property name="label" translatable="yes">Donate</property> <property name="label" translatable="yes">Donate</property>
<property name="name">donatebtn</property> <property name="name">donate</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="on_link_btn_clicked" swapped="no"/> <signal name="clicked" handler="on_link_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@ -315,7 +315,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
<property name="name">google+</property> <property name="name">google+</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="button-press-event" handler="on_social_pressed" swapped="no"/> <signal name="button-press-event" handler="on_link_clicked" swapped="no"/>
<child> <child>
<object class="GtkImage" id="google+"> <object class="GtkImage" id="google+">
<property name="visible">True</property> <property name="visible">True</property>
@ -334,7 +334,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
<property name="name">facebook</property> <property name="name">facebook</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="button-press-event" handler="on_social_pressed" swapped="no"/> <signal name="button-press-event" handler="on_link_clicked" swapped="no"/>
<child> <child>
<object class="GtkImage" id="facebook"> <object class="GtkImage" id="facebook">
<property name="visible">True</property> <property name="visible">True</property>
@ -353,7 +353,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
<property name="name">twitter</property> <property name="name">twitter</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="button-press-event" handler="on_social_pressed" swapped="no"/> <signal name="button-press-event" handler="on_link_clicked" swapped="no"/>
<child> <child>
<object class="GtkImage" id="twitter"> <object class="GtkImage" id="twitter">
<property name="visible">True</property> <property name="visible">True</property>
@ -372,7 +372,7 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
<property name="name">reddit</property> <property name="name">reddit</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="button-press-event" handler="on_social_pressed" swapped="no"/> <signal name="button-press-event" handler="on_link_clicked" swapped="no"/>
<child> <child>
<object class="GtkImage" id="reddit"> <object class="GtkImage" id="reddit">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -17,15 +17,13 @@ class ManjaroHello():
self.app = "manjaro-hello" self.app = "manjaro-hello"
self.default_locale = "en_US" self.default_locale = "en_US"
self.sys_locale = locale.getdefaultlocale()[0] self.sys_locale = locale.getdefaultlocale()[0]
self.welcome_urls = { self.urls = {
"wiki": "https://wiki.manjaro.org", "wiki": "https://wiki.manjaro.org",
"forums": "https://forum.manjaro.org", "forums": "https://forum.manjaro.org",
"chat": "https://kiwiirc.com/client/irc.freenode.net/?nick=manjaro-web|?#manjaro", "chat": "https://kiwiirc.com/client/irc.freenode.net/?nick=manjaro-web|?#manjaro",
"mailling": "https://lists.manjaro.org/cgi-bin/mailman/listinfo", "mailling": "https://lists.manjaro.org/cgi-bin/mailman/listinfo",
"build": "https://github.com/manjaro", "build": "https://github.com/manjaro",
"donate": "https://manjaro.org/donate" "donate": "https://manjaro.org/donate",
}
self.social_urls = {
"google+": "https://plus.google.com/118244873957924966264", "google+": "https://plus.google.com/118244873957924966264",
"facebook": "https://www.facebook.com/ManjaroLinux", "facebook": "https://www.facebook.com/ManjaroLinux",
"twitter": "https://twitter.com/ManjaroLinux", "twitter": "https://twitter.com/ManjaroLinux",
@ -115,23 +113,23 @@ class ManjaroHello():
# Dirty code to fix an issue with gettext that can't translate text from glade interface # Dirty code to fix an issue with gettext that can't translate text from glade interface
# TODO: Find a better solution # TODO: Find a better solution
elts = { elts = {
"welcometitle": "label",
"welcomelabel": "label", "welcomelabel": "label",
"welcometext": "label",
"documentationtitle": "label",
"readmelabel": "label", "readmelabel": "label",
"releaselabel": "label", "releaselabel": "label",
"involvedlabel": "label", "involvedlabel": "label",
"supporttitle": "label", "firstcategory": "label",
"projecttitle": "label", "secondcategory": "label",
"readmebtn": "label", "thirdcategory": "label",
"releasebtn": "label", "readme": "label",
"wikibtn": "label", "release": "label",
"involvedbtn": "label", "wiki": "label",
"forumsbtn": "label", "involved": "label",
"chatbtn": "label", "forums": "label",
"maillingbtn": "label", "chat": "label",
"buildbtn": "label", "mailling": "label",
"donatebtn": "label", "build": "label",
"donate": "label",
"installlabel": "label", "installlabel": "label",
"installgui": "label", "installgui": "label",
"installcli": "label", "installcli": "label",
@ -203,13 +201,13 @@ class ManjaroHello():
def on_action_btn_clicked(self, btn): def on_action_btn_clicked(self, btn):
name = btn.get_name() name = btn.get_name()
if name == "readmebtn": if name == "readme":
self.builder.get_object("stack").set_visible_child(self.builder.get_object("documentation")) self.builder.get_object("stack").set_visible_child(self.builder.get_object("documentation"))
self.builder.get_object("documentation").set_current_page(0) self.builder.get_object("documentation").set_current_page(0)
elif name == "releasebtn": elif name == "release":
self.builder.get_object("stack").set_visible_child(self.builder.get_object("documentation")) self.builder.get_object("stack").set_visible_child(self.builder.get_object("documentation"))
self.builder.get_object("documentation").set_current_page(1) self.builder.get_object("documentation").set_current_page(1)
elif name == "involvedbtn": elif name == "involved":
self.builder.get_object("stack").set_visible_child(self.builder.get_object("project")) self.builder.get_object("stack").set_visible_child(self.builder.get_object("project"))
self.builder.get_object("project").set_current_page(0) self.builder.get_object("project").set_current_page(0)
elif name == "installgui": elif name == "installgui":
@ -217,11 +215,8 @@ class ManjaroHello():
elif name == "installcli": elif name == "installcli":
subprocess.call(["sudo cli-installer"]) subprocess.call(["sudo cli-installer"])
def on_link_btn_clicked(self, btn): def on_link_clicked(self, link, _=None):
webbrowser.open_new_tab(self.welcome_urls[btn.get_name()[:-3]]) webbrowser.open_new_tab(self.urls[link.get_name()])
def on_social_pressed(self, eventbox, _):
webbrowser.open_new_tab(self.social_urls[eventbox.get_name()])
def on_autostart_switched(self, switch, _): def on_autostart_switched(self, switch, _):
autostart = True if switch.get_active() else False autostart = True if switch.get_active() else False