Skip to content

Commit d933efd

Browse files
committed
Support both LibAdwaita and LibAdapta
1 parent e5fac68 commit d933efd

File tree

7 files changed

+322
-28
lines changed

7 files changed

+322
-28
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ Find info about an IP address.
1616

1717
Or download [latest artifact zip](https://nightly.link/Bytezz/IPLookup-gtk/workflows/ci/main) for your architecture,
1818
extract and install the enclosed flatpak.
19+
20+
## LibAdapta Support
21+
22+
To switch from default LibAdwaita to LibAdapta, set the environment variable `LIBADAPTA=1`:
23+
24+
```bash
25+
flatpak override --user --env=LIBADAPTA=1
26+
```

flatpak/io.github.bytezz.IPLookup.Devel.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,52 @@
2323
"*.a"
2424
],
2525
"modules" : [
26+
{
27+
"name" : "libadapta",
28+
"buildsystem" : "meson",
29+
"config-opts" : [
30+
"-Dexamples=false",
31+
"-Dtests=false",
32+
"-Dgtk_doc=false"
33+
],
34+
"sources" : [
35+
{
36+
"type" : "git",
37+
"url" : "https://github.com/xapp-project/libadapta.git",
38+
"branch" : "1.5.x"
39+
}
40+
],
41+
"modules" : [
42+
{
43+
"name" : "libsass",
44+
"buildsystem" : "meson",
45+
"cleanup" : [
46+
"*"
47+
],
48+
"sources" : [
49+
{
50+
"type" : "git",
51+
"url" : "https://github.com/lazka/libsass.git",
52+
"branch" : "meson"
53+
}
54+
]
55+
},
56+
{
57+
"name" : "sassc",
58+
"buildsystem" : "meson",
59+
"cleanup" : [
60+
"*"
61+
],
62+
"sources" : [
63+
{
64+
"type" : "git",
65+
"url" : "https://github.com/lazka/sassc.git",
66+
"branch" : "meson"
67+
}
68+
]
69+
}
70+
]
71+
},
2672
{
2773
"name" : "iplookup",
2874
"builddir" : true,

src/iplookup.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<gresources>
33
<gresource prefix="/io/github/bytezz/IPLookup">
44
<file preprocess="xml-stripblanks">window.ui</file>
5+
<file preprocess="xml-stripblanks">window-libadapta.ui</file>
56
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
67
</gresource>
78
<gresource prefix="/io/github/bytezz/IPLookup/icons/scalable/actions/">

src/main.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@
1717
#
1818
# SPDX-License-Identifier: GPL-3.0-or-later
1919

20-
import sys
20+
import sys, os
2121
import gi
2222

2323
gi.require_version('Gtk', '4.0')
24-
#gi.require_version('Adw', '1')
25-
gi.require_version('Adap', '1')
24+
gi.require_version(
25+
('Adap' if os.environ.get("LIBADAPTA") == "1" else 'Adw'),
26+
'1'
27+
)
2628

2729
from gi.repository import Gtk, Gio
28-
from gi.repository import Adap as Adw
30+
if os.environ.get("LIBADAPTA") == "1":
31+
from gi.repository import Adap as Adw
32+
else:
33+
from gi.repository import Adw
2934
from .window import IplookupWindow
3035

3136
from . import ipapi

src/window-libadapta.ui

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<requires lib="gtk" version="4.0"/>
4+
<requires lib="Adw" version="1.0"/>
5+
<template class="IplookupWindow" parent="AdapApplicationWindow">
6+
<property name="default-width">450</property>
7+
<property name="default-height">715</property>
8+
<property name="title" translatable="yes">IP Lookup</property>
9+
<child>
10+
<object class="AdapToolbarView">
11+
<child type="top">
12+
<object class="AdapHeaderBar" id="header_bar">
13+
<child type="end">
14+
<object class="GtkMenuButton">
15+
<property name="tooltip-text" translatable="yes">Main Menu</property>
16+
<property name="icon-name">open-menu-symbolic</property>
17+
<property name="menu-model">primary_menu</property>
18+
<property name="primary">True</property>
19+
</object>
20+
</child>
21+
</object>
22+
</child>
23+
<property name="content">
24+
<object class="AdapToastOverlay" id="toast">
25+
<child>
26+
<object class="GtkScrolledWindow">
27+
<property name="vexpand">True</property>
28+
<child>
29+
<object class="GtkViewport">
30+
<child>
31+
<object class="AdapClamp">
32+
<property name="margin-top">10</property>
33+
<property name="margin-start">10</property>
34+
<property name="margin-end">10</property>
35+
<child>
36+
<object class="GtkBox">
37+
<property name="orientation">vertical</property>
38+
<property name="spacing">10</property>
39+
<child>
40+
<object class="AdapPreferencesGroup">
41+
<child>
42+
<!-- TODO: Move this to headerbar as GtkEntry? -->
43+
<object class="AdapEntryRow" id="ip_entry">
44+
<property name="title" translatable="yes">IP</property>
45+
<!-- Is possible to change apply-button icon? -->
46+
<property name="show-apply-button">True</property>
47+
<!--child>
48+
<object class="GtkButton" id="search_btn">
49+
<property name="label">Search</property>
50+
<property name="icon-name">search-symbolic</property>
51+
<property name="css-classes">flat</property>
52+
<property name="margin-top">10</property>
53+
<property name="margin-bottom">10</property>
54+
</object>
55+
</child-->
56+
</object>
57+
</child>
58+
</object>
59+
</child>
60+
<child>
61+
<object class="AdapPreferencesGroup">
62+
<property name="title" translatable="yes">Network</property>
63+
<child>
64+
<object class="AdapExpanderRow" id="ip_row">
65+
<property name="title" translatable="yes">IP</property>
66+
<property name="icon-name">globe-symbolic</property>
67+
<property name="visible">False</property>
68+
</object>
69+
</child>
70+
<child>
71+
<object class="AdapActionRow">
72+
<property name="title" translatable="yes">Network</property>
73+
<property name="icon-name">lan-symbolic</property>
74+
<child>
75+
<object class="GtkLabel" id="network_label">
76+
<property name="label"></property>
77+
<property name="selectable">True</property>
78+
</object>
79+
</child>
80+
</object>
81+
</child>
82+
<child>
83+
<object class="AdapActionRow">
84+
<property name="title" translatable="yes">ISP</property>
85+
<property name="icon-name">globe-symbolic</property>
86+
<child>
87+
<object class="GtkLabel" id="isp_label">
88+
<property name="label"></property>
89+
<property name="selectable">True</property>
90+
</object>
91+
</child>
92+
</object>
93+
</child>
94+
<child>
95+
<object class="AdapActionRow">
96+
<property name="title" translatable="yes">Org</property>
97+
<property name="icon-name">building-symbolic</property>
98+
<child>
99+
<object class="GtkLabel" id="org_label">
100+
<property name="label"></property>
101+
<property name="selectable">True</property>
102+
</object>
103+
</child>
104+
</object>
105+
</child>
106+
</object>
107+
</child>
108+
<child>
109+
<object class="AdapPreferencesGroup">
110+
<property name="title" translatable="yes">Geo</property>
111+
<property name="margin-bottom">10</property>
112+
<child>
113+
<object class="AdapActionRow">
114+
<property name="title" translatable="yes">City</property>
115+
<property name="icon-name">city-symbolic</property>
116+
<child>
117+
<object class="GtkLabel" id="city_label">
118+
<property name="label"></property>
119+
<property name="selectable">True</property>
120+
</object>
121+
</child>
122+
</object>
123+
</child>
124+
<child>
125+
<object class="AdapActionRow">
126+
<property name="title" translatable="yes">Region</property>
127+
<property name="icon-name">flag-outline-thick-symbolic</property>
128+
<child>
129+
<object class="GtkLabel" id="region_label">
130+
<property name="label"></property>
131+
<property name="selectable">True</property>
132+
</object>
133+
</child>
134+
</object>
135+
</child>
136+
<child>
137+
<object class="AdapActionRow">
138+
<property name="title" translatable="yes">Country</property>
139+
<property name="icon-name">flag-filled-symbolic</property>
140+
<child>
141+
<object class="GtkLabel" id="country_label">
142+
<property name="label"></property>
143+
<property name="selectable">True</property>
144+
</object>
145+
</child>
146+
</object>
147+
</child>
148+
<child>
149+
<object class="AdapActionRow">
150+
<property name="title" translatable="yes">Zip</property>
151+
<property name="icon-name">mail-symbolic</property>
152+
<child>
153+
<object class="GtkLabel" id="zip_label">
154+
<property name="label"></property>
155+
<property name="selectable">True</property>
156+
</object>
157+
</child>
158+
</object>
159+
</child>
160+
<child>
161+
<object class="AdapActionRow">
162+
<property name="title" translatable="yes">Timezone</property>
163+
<property name="icon-name">clock-alt-symbolic</property>
164+
<child>
165+
<object class="GtkLabel" id="timezone_label">
166+
<property name="label"></property>
167+
<property name="selectable">True</property>
168+
</object>
169+
</child>
170+
</object>
171+
</child>
172+
<child>
173+
<object class="AdapActionRow">
174+
<property name="title" translatable="yes">Coordinates</property>
175+
<property name="icon-name">map-marker-symbolic</property>
176+
<child>
177+
<object class="GtkLinkButton" id="coordinates_label">
178+
<property name="label"></property>
179+
<property name="uri"></property>
180+
<property name="tooltip-text" translatable="yes">Open map</property>
181+
<property name="visible">False</property>
182+
</object>
183+
</child>
184+
</object>
185+
</child>
186+
</object>
187+
</child>
188+
</object>
189+
</child>
190+
</object>
191+
</child>
192+
</object>
193+
</child>
194+
</object>
195+
</child>
196+
</object>
197+
</property>
198+
</object>
199+
</child>
200+
</template>
201+
<menu id="primary_menu">
202+
<section>
203+
<item>
204+
<attribute name="label" translatable="yes">_Get Your IP</attribute>
205+
<attribute name="action">app.get-your-ip</attribute>
206+
</item>
207+
</section>
208+
<section>
209+
<item>
210+
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
211+
<attribute name="action">win.show-help-overlay</attribute>
212+
</item>
213+
<item>
214+
<attribute name="label" translatable="yes">_About IP Lookup</attribute>
215+
<attribute name="action">app.about</attribute>
216+
</item>
217+
</section>
218+
</menu>
219+
<object class="AdapMessageDialog" id="error_dialog">
220+
<property name="heading">Error</property>
221+
<property name="body">Error message.</property>
222+
<property name="default-response">close</property>
223+
<property name="close-response">close</property>
224+
<responses>
225+
<response id="close" translatable="yes">_Close</response>
226+
</responses>
227+
</object>
228+
</interface>

src/window.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
#
1818
# SPDX-License-Identifier: GPL-3.0-or-later
1919

20-
from gi.repository import Adap as Adw
21-
from gi.repository import Gtk
22-
from gi.repository import Gio
20+
import os
2321

24-
@Gtk.Template(resource_path='/io/github/bytezz/IPLookup/window.ui')
22+
from gi.repository import Gtk, Gio
23+
if os.environ.get("LIBADAPTA") == "1":
24+
from gi.repository import Adap as Adw
25+
resource_path = "/io/github/bytezz/IPLookup/window-libadapta.ui"
26+
else:
27+
from gi.repository import Adw
28+
resource_path = "/io/github/bytezz/IPLookup/window.ui"
29+
30+
@Gtk.Template(resource_path=resource_path)
2531
class IplookupWindow(Adw.ApplicationWindow):
2632
__gtype_name__ = 'IplookupWindow'
2733

0 commit comments

Comments
 (0)