Skip to content

Commit

Permalink
Add con workspace method
Browse files Browse the repository at this point in the history
This method gets the workspace that the con is currently on.
  • Loading branch information
Tony Crisci committed Mar 26, 2014
1 parent f194303 commit 33e582b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions i3ipc-glib/i3ipc-con.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,22 @@ i3ipcCon *i3ipc_con_find_focused(i3ipcCon *self) {

return retval;
}

/**
* i3ipc_con_workspace:
* @self: an #i3ipcCon
*
* Returns: (transfer none): The closest workspace con
*/
i3ipcCon *i3ipc_con_workspace(i3ipcCon *self) {
i3ipcCon *retval = self->priv->parent;

while (retval != NULL) {
if (g_strcmp0(retval->priv->type, "workspace") == 0)
break;

retval = retval->priv->parent;
}

return retval;
}
2 changes: 2 additions & 0 deletions i3ipc-glib/i3ipc-con.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@ GList *i3ipc_con_workspaces(i3ipcCon *self);

i3ipcCon *i3ipc_con_find_focused(i3ipcCon *self);

i3ipcCon *i3ipc_con_workspace(i3ipcCon *self);

#endif

0 comments on commit 33e582b

Please sign in to comment.