Skip to content

Commit

Permalink
Merge pull request #73 from regolith-linux/rename_i3_references
Browse files Browse the repository at this point in the history
window manager agnostic renames
  • Loading branch information
kgilmer authored Jul 23, 2023
2 parents 98ea293 + c3a03f8 commit 877a2df
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/keybindings/ConfigParser.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This class retrieves the i3 config file over IPC and
* This class retrieves the wm config file over IPC and
* produces a [Category] -> List<Keybinding> data structure
* indended to be presented to the user.
*/
Expand Down Expand Up @@ -33,7 +33,7 @@ public class ConfigParser {
this.line_prefix = line_prefix;
}

public Map<string, ArrayList<Keybinding> > parse () throws PARSE_ERROR, GLib.Error, Ilia.I3_ERROR {
public Map<string, ArrayList<Keybinding> > parse () throws PARSE_ERROR, GLib.Error, Ilia.WM_ERROR {
string[] lines = config.split ("\n");

if (lines == null || lines.length == 0) return Map.empty<string, ArrayList<Keybinding> >(); ;
Expand Down
32 changes: 16 additions & 16 deletions src/keybindings/I3Ipc.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using GLib;
using Gee;

namespace Ilia {
enum I3_COMMAND {
enum WM_COMMAND {
RUN_COMMAND,
GET_WORKSPACES,
SUBSCRIBE,
Expand All @@ -21,7 +21,7 @@ namespace Ilia {
SYNC
}

public errordomain I3_ERROR {
public errordomain WM_ERROR {
RPC_ERROR
}

Expand Down Expand Up @@ -250,14 +250,14 @@ namespace Ilia {
}
}

public class I3Client {
public class IPCClient {
private Socket socket;
private uint8[] magic_number = "i3-ipc".data;
private uint8[] terminator = { '\0' };
private int bytes_to_payload = 14;
private int buffer_size = 1024 * 128;

public I3Client () throws GLib.Error {
public IPCClient () throws GLib.Error {
var socket_path = Environment.get_variable ("I3SOCK");

var socketAddress = new UnixSocketAddress (socket_path);
Expand All @@ -269,7 +269,7 @@ namespace Ilia {
socket.set_blocking (true);
}

~I3Client () {
~IPCClient () {
if (socket != null) {
try {
socket.close ();
Expand All @@ -293,7 +293,7 @@ namespace Ilia {
return (string) b.data;
}

private uint8[] generate_request (I3_COMMAND cmd) {
private uint8[] generate_request (WM_COMMAND cmd) {
ByteArray np = new ByteArray ();

np.append (magic_number);
Expand All @@ -305,7 +305,7 @@ namespace Ilia {
return message.get_data ();
}

private Json.Node ? i3_ipc (I3_COMMAND command) throws GLib.Error {
private Json.Node ? wm_ipc (WM_COMMAND command) throws GLib.Error {
ssize_t sent = socket.send (generate_request (command));

debug ("Sent " + sent.to_string () + " bytes to " + WM_NAME + ".\n");
Expand All @@ -325,31 +325,31 @@ namespace Ilia {
return parser.get_root ();
}

public VersionReply getVersion () throws I3_ERROR, GLib.Error {
var response = i3_ipc (I3_COMMAND.GET_VERSION);
public VersionReply getVersion () throws WM_ERROR, GLib.Error {
var response = wm_ipc (WM_COMMAND.GET_VERSION);

if (response == null) {
throw new I3_ERROR.RPC_ERROR ("No Response");
throw new WM_ERROR.RPC_ERROR ("No Response");
}

return new VersionReply (response);
}

public ConfigReply getConfig () throws I3_ERROR, GLib.Error {
var response = i3_ipc (I3_COMMAND.GET_CONFIG);
public ConfigReply getConfig () throws WM_ERROR, GLib.Error {
var response = wm_ipc (WM_COMMAND.GET_CONFIG);

if (response == null) {
throw new I3_ERROR.RPC_ERROR ("No Response");
throw new WM_ERROR.RPC_ERROR ("No Response");
}

return new ConfigReply (response);
}

public TreeReply getTree () throws I3_ERROR, GLib.Error {
var response = i3_ipc (I3_COMMAND.GET_TREE);
public TreeReply getTree () throws WM_ERROR, GLib.Error {
var response = wm_ipc (WM_COMMAND.GET_TREE);

if (response == null) {
throw new I3_ERROR.RPC_ERROR ("No Response");
throw new WM_ERROR.RPC_ERROR ("No Response");
}

return new TreeReply (response);
Expand Down
12 changes: 6 additions & 6 deletions src/keybindings/KeybindingsPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ namespace Ilia {

create_item_view ();

read_i3_config.begin ((obj, res) => {
read_i3_config.end (res);
read_config.begin ((obj, res) => {
read_config.end (res);

item_view.columns_autosize ();
model.set_sort_column_id (1, SortType.ASCENDING);
Expand Down Expand Up @@ -161,11 +161,11 @@ namespace Ilia {
}
}

// Read the active i3 configuration and populate the model with keybindings
private async void read_i3_config () {
// Read the active configuration and populate the model with keybindings
private async void read_config () {
try {
var i3_client = new I3Client ();
var config_file = i3_client.getConfig ().config;
var ipc_client = new IPCClient ();
var config_file = ipc_client.getConfig ().config;
var parser = new ConfigParser (config_file, "");

Map<string, ArrayList<Keybinding> > kbmodel = parser.parse ();
Expand Down
6 changes: 3 additions & 3 deletions src/windows/WindowPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ namespace Ilia {

private void load_windows () {
try {
var i3_client = new I3Client ();
var node = i3_client.getTree ();
var ipc_client = new IPCClient ();
var node = ipc_client.getTree ();

if (node != null) {
icon_theme = Gtk.IconTheme.get_default ();
Expand Down Expand Up @@ -268,4 +268,4 @@ namespace Ilia {
}
}
}
}
}

0 comments on commit 877a2df

Please sign in to comment.