Add button to fetch current IP address
This commit is contained in:
@@ -60,15 +60,6 @@ public class Allesapp.Application : Adw.Application {
|
|||||||
|
|
||||||
private void on_preferences_action () {
|
private void on_preferences_action () {
|
||||||
message ("app.preferences action activated");
|
message ("app.preferences action activated");
|
||||||
|
|
||||||
var session = new Soup.Session ();
|
|
||||||
var msg = new Soup.Message ("GET", "http://ip4.clerie.de");
|
|
||||||
|
|
||||||
var input_stream = session.send (msg);
|
|
||||||
var data_input_stream = new DataInputStream (input_stream);
|
|
||||||
|
|
||||||
message (data_input_stream.read_line_utf8());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,50 +1,69 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!-- Created with Cambalache 0.94.1 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk" version="4.0"/>
|
<!-- interface-name window.ui -->
|
||||||
<requires lib="Adw" version="1.0"/>
|
<requires lib="Adw" version="1.0"/>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<requires lib="gio" version="2.0"/>
|
||||||
|
<requires lib="libadwaita" version="1.4"/>
|
||||||
<template class="AllesappWindow" parent="AdwApplicationWindow">
|
<template class="AllesappWindow" parent="AdwApplicationWindow">
|
||||||
<property name="title" translatable="yes">Allesapp</property>
|
|
||||||
<property name="default-width">800</property>
|
|
||||||
<property name="default-height">600</property>
|
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar">
|
<object class="AdwHeaderBar">
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkMenuButton">
|
<object class="GtkMenuButton">
|
||||||
<property name="primary">True</property>
|
|
||||||
<property name="icon-name">open-menu-symbolic</property>
|
<property name="icon-name">open-menu-symbolic</property>
|
||||||
<property name="tooltip-text" translatable="yes">Main Menu</property>
|
|
||||||
<property name="menu-model">primary_menu</property>
|
<property name="menu-model">primary_menu</property>
|
||||||
|
<property name="primary">True</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Main Menu</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<property name="content">
|
<child>
|
||||||
<object class="GtkLabel" id="label">
|
<object class="AdwClampScrollable">
|
||||||
<property name="label" translatable="yes">Hello, World!</property>
|
<property name="child">
|
||||||
<style>
|
<object class="GtkBox">
|
||||||
<class name="title-1"/>
|
<property name="orientation">vertical</property>
|
||||||
</style>
|
<child>
|
||||||
|
<object class="GtkLabel" id="my_ip_address_label">
|
||||||
|
<property name="label">Meowwww</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="fetch_my_ip_address">
|
||||||
|
<property name="icon-name">processes-symbolic</property>
|
||||||
|
<property name="label">Fetch my IP address</property>
|
||||||
|
<signal name="clicked" handler="on_fetch_my_ip_address"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="default-height">600</property>
|
||||||
|
<property name="default-width">800</property>
|
||||||
|
<property name="title" translatable="yes">Allesapp</property>
|
||||||
</template>
|
</template>
|
||||||
<menu id="primary_menu">
|
<menu id="primary_menu">
|
||||||
<section>
|
<section>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_Preferences</attribute>
|
|
||||||
<attribute name="action">app.preferences</attribute>
|
<attribute name="action">app.preferences</attribute>
|
||||||
|
<attribute name="label" translatable="yes">_Preferences</attribute>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
|
||||||
<attribute name="action">win.show-help-overlay</attribute>
|
<attribute name="action">win.show-help-overlay</attribute>
|
||||||
|
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_About Allesapp</attribute>
|
|
||||||
<attribute name="action">app.about</attribute>
|
<attribute name="action">app.about</attribute>
|
||||||
|
<attribute name="label" translatable="yes">_About Allesapp</attribute>
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
|
<object class="GtkButton"/>
|
||||||
|
<object class="AdwClampScrollable"/>
|
||||||
</interface>
|
</interface>
|
||||||
|
@@ -21,9 +21,22 @@
|
|||||||
[GtkTemplate (ui = "/de/clerie/allesapp/window.ui")]
|
[GtkTemplate (ui = "/de/clerie/allesapp/window.ui")]
|
||||||
public class Allesapp.Window : Adw.ApplicationWindow {
|
public class Allesapp.Window : Adw.ApplicationWindow {
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
private unowned Gtk.Label label;
|
private unowned Gtk.Label my_ip_address_label;
|
||||||
|
|
||||||
public Window (Gtk.Application app) {
|
public Window (Gtk.Application app) {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback]
|
||||||
|
private void on_fetch_my_ip_address () {
|
||||||
|
|
||||||
|
var session = new Soup.Session ();
|
||||||
|
var msg = new Soup.Message ("GET", "http://ip6.clerie.de");
|
||||||
|
|
||||||
|
var input_stream = session.send (msg);
|
||||||
|
var data_input_stream = new DataInputStream (input_stream);
|
||||||
|
|
||||||
|
my_ip_address_label.set_label (data_input_stream.read_line_utf8());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user