Skip to content

Commit

Permalink
V40 compatibility update
Browse files Browse the repository at this point in the history
  • Loading branch information
kgshank committed Mar 28, 2021
1 parent 7281cf1 commit d63b666
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 120 deletions.
5 changes: 3 additions & 2 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"3.32",
"3.34",
"3.36",
"3.38"
"3.38",
"40"
],
"uuid": "[email protected]",
"name": "Disconnect Wifi",
"description": "Adds a Disconnect option for Wifi in status menu, when a network is connected. Shows a Reconnect option, after network is disconnected.",
"version": "26",
"version": "27",
"original-author": "GopI",
"url": "https://github.com/kgshank/gse-disconnect-wifi"
}
18 changes: 14 additions & 4 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,24 @@ const DWifiSettingsWidget = new GObject.Class({

_init : function(params) {
this.parent(params);
let uiFileSuffix = "";
if (Gtk.get_major_version() >= "4") {
uiFileSuffix = "40";
this.__addFn = this.append;
this.__showFn = this.show;
}
else {
this.__addFn = x => this.pack_start(x, true, true, 0);
this.__showFn = this.show_all;
}
this.orientation = Gtk.Orientation.VERTICAL;
this.spacing = 0;

// creates the settings
this._settings = Lib.getSettings(SETTINGS_SCHEMA);

// creates the ui builder and add the main resource file
let uiFilePath = Me.path + "/ui/dwifi-prefs-dialog.glade";
let uiFilePath = Me.path + "/ui/dwifi-prefs-dialog" +uiFileSuffix +".glade";
let builder = new Gtk.Builder();

if (builder.add_from_file(uiFilePath) == 0) {
Expand All @@ -59,13 +69,13 @@ const DWifiSettingsWidget = new GObject.Class({
vexpand : true
});

this.pack_start(label, true, true, 0);
this.__addFn(label);
} else {
_l('JS LOG:_UI file receive and load: ' + uiFilePath);

let mainContainer = builder.get_object("main-container");

this.pack_start(mainContainer, true, true, 0);
this.__addFn(mainContainer);

this._signalManager = new SignalManager();

Expand All @@ -81,7 +91,7 @@ const DWifiSettingsWidget = new GObject.Class({

function buildPrefsWidget() {
let _settingsWidget = new DWifiSettingsWidget();
_settingsWidget.show_all();
_settingsWidget.__showFn();

return _settingsWidget;
}
171 changes: 57 additions & 114 deletions [email protected]/ui/dwifi-prefs-dialog.glade
Original file line number Diff line number Diff line change
@@ -1,146 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkListStore" id="icon-theme-store">
<columns>
<!-- column-name Key -->
<column type="gchararray"/>
<!-- column-name Value -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">monochrome</col>
<col id="1" translatable="yes">Monochrome</col>
</row>
<row>
<col id="0">colored</col>
<col id="1" translatable="yes">Colored</col>
</row>
<row>
<col id="0">none</col>
<col id="1" translatable="yes">None</col>
</row>
</data>
</object>
<object class="GtkBox" id="main-container">
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="can-focus">False</property>


<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkBox">
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="homogeneous">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">out</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">6</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkFrame">

<object class="GtkListBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">out</property>
<property name="can-focus">False</property>
<property name="selection-mode">none</property>
<child>
<object class="GtkAlignment">
<object class="GtkListBoxRow">
<property name="width-request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">True</property>
<child>
<object class="GtkListBox">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<property name="can-focus">False</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>


<property name="label" translatable="yes">Always show Reconnect option</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBoxRow">
<property name="width_request">100</property>
<object class="GtkSwitch" id="show-reconnect-always">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">10</property>
<property name="label" translatable="yes">Always show Reconnect option</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="show-reconnect-always">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="margin_left">10</property>
<property name="margin_right">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<property name="can-focus">True</property>
<property name="halign">end</property>


</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">General Settings</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>

</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">General Settings</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
</object>
Expand Down

0 comments on commit d63b666

Please sign in to comment.