Skip to content

Commit

Permalink
Merge pull request #33 from Araxor/master
Browse files Browse the repository at this point in the history
Workspaces filtering by monitor (output) name
  • Loading branch information
denesb authored Nov 5, 2016
2 parents 7b0f19a + 43613e3 commit e0a5c93
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
25 changes: 25 additions & 0 deletions panel-plugin/i3w-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void
urgent_color_changed(GtkWidget *button, i3WorkspacesConfig *config);
void
strip_workspace_numbers_changed(GtkWidget *button, i3WorkspacesConfig *config);
void
output_changed(GtkWidget *entry, i3WorkspacesConfig *config);

void
config_dialog_closed(GtkWidget *dialog, int response, ConfigDialogClosedParam *param);
Expand Down Expand Up @@ -94,6 +96,7 @@ i3_workspaces_config_new()
void
i3_workspaces_config_free(i3WorkspacesConfig *config)
{
g_free(config->output);
g_free(config);
}

Expand All @@ -112,6 +115,7 @@ i3_workspaces_config_load(i3WorkspacesConfig *config, XfcePanelPlugin *plugin)
config->urgent_color = xfce_rc_read_int_entry(rc, "urgent_color", 0xff0000);
config->strip_workspace_numbers = xfce_rc_read_bool_entry(rc,
"strip_workspace_numbers", FALSE);
config->output = g_strdup(xfce_rc_read_entry(rc, "output", ""));

xfce_rc_close(rc);

Expand All @@ -133,6 +137,7 @@ i3_workspaces_config_save(i3WorkspacesConfig *config, XfcePanelPlugin *plugin)
xfce_rc_write_int_entry(rc, "urgent_color", config->urgent_color);
xfce_rc_write_bool_entry(rc, "strip_workspace_numbers",
config->strip_workspace_numbers);
xfce_rc_write_entry(rc, "output", config->output);

xfce_rc_close(rc);

Expand Down Expand Up @@ -206,6 +211,20 @@ i3_workspaces_config_show(i3WorkspacesConfig *config, XfcePanelPlugin *plugin,
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), config->strip_workspace_numbers == TRUE);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(strip_workspace_numbers_changed), config);

/* output */
hbox = gtk_hbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);

label = gtk_label_new(_("Output:"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

button = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_entry_set_text(GTK_ENTRY(button), config->output);
g_signal_connect(G_OBJECT(button), "changed", G_CALLBACK(output_changed), config);


/* close event */
ConfigDialogClosedParam *param = g_new(ConfigDialogClosedParam, 1);
param->plugin = plugin;
Expand All @@ -223,6 +242,12 @@ strip_workspace_numbers_changed(GtkWidget *button, i3WorkspacesConfig *config)
config->strip_workspace_numbers = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
}

void
output_changed(GtkWidget *entry, i3WorkspacesConfig *config)
{
config->output = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
}

void
normal_color_changed(GtkWidget *button, i3WorkspacesConfig *config)
{
Expand Down
1 change: 1 addition & 0 deletions panel-plugin/i3w-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef struct
guint32 focused_color;
guint32 urgent_color;
gboolean strip_workspace_numbers;
gchar *output;
}
i3WorkspacesConfig;

Expand Down
4 changes: 3 additions & 1 deletion panel-plugin/i3w-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ add_workspaces(i3WorkspacesPlugin *i3_workspaces)
for (witem = wlist; witem != NULL; witem = witem->next)
{
i3workspace *workspace = (i3workspace *) witem->data;
if (workspace)
if (workspace &&
(i3_workspaces->config->output[0] == 0 ||
g_strcmp0(i3_workspaces->config->output, workspace->output)))
{
GtkWidget * button;
button = xfce_panel_create_button();
Expand Down
2 changes: 2 additions & 0 deletions panel-plugin/i3wm-delegate.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ create_workspace(i3ipcWorkspaceReply * wreply)
workspace->name = g_strdup(wreply->name);
workspace->focused = wreply->focused;
workspace->urgent = wreply->urgent;
workspace->output = g_strdup(wreply->output);

return workspace;
}
Expand All @@ -337,6 +338,7 @@ void
destroy_workspace(i3workspace *workspace)
{
g_free(workspace->name);
g_free(workspace->output);
g_free(workspace);
}

Expand Down
1 change: 1 addition & 0 deletions panel-plugin/i3wm-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef struct _i3workspace
gchar *name;
gboolean focused;
gboolean urgent;
gchar *output;
} i3workspace;

typedef void (*i3wmWorkspaceCallback) (i3workspace *workspace, gpointer data);
Expand Down

0 comments on commit e0a5c93

Please sign in to comment.