Update some styles

This commit is contained in:
asonix 2021-05-06 17:24:59 -05:00
parent b21f66df26
commit 3c587e38e1
11 changed files with 88 additions and 61 deletions

View file

@ -114,6 +114,9 @@ public class Streamdeck.Daemon : Object {
});
commands_signal.connect ((_obj, serial_number, new_commands) => {
if (commands.has_key (serial_number)) {
commands.unset (serial_number);
}
commands.set (serial_number, new_commands);
});
@ -263,6 +266,9 @@ public class Streamdeck.Daemon : Object {
input_names.set (serial_number, new Gee.HashMap<uint8, string> ());
}
var hm = input_names.get (serial_number);
if (hm.has_key (name.key)) {
hm.unset (name.key);
}
hm.set (name.key, name.name);
input_name_signal (serial_number, name.key, name.name);
}

View file

@ -27,7 +27,7 @@ namespace Streamdeck.Dialogs {
response.connect ((response_id) => {
if (response_id == Gtk.ResponseType.REJECT) {
unowned var app = (MainWindow) transient_for;
var app = (MainWindow) transient_for;
app.to_obs ();
}

View file

@ -15,8 +15,12 @@ namespace Streamdeck.Dialogs {
var press_label = new Gtk.Label (
_("Please press the button you wish to program on your stream deck")
);
press_label.valign = Gtk.Align.CENTER;
press_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
press_label.hexpand = true;
press_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
press_label.max_width_chars = 30;
press_label.wrap = true;
press_label.wrap_mode = Pango.WrapMode.WORD_CHAR;
press_label.xalign = 0;
var press_page = new Gtk.Grid ();
press_page.column_spacing = 12;
@ -29,8 +33,12 @@ namespace Streamdeck.Dialogs {
var existing_key_label = new Gtk.Label (
_("Key already mapped, try pressing a new key")
);
existing_key_label.valign = Gtk.Align.CENTER;
existing_key_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
existing_key_label.hexpand = true;
existing_key_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
existing_key_label.max_width_chars = 30;
existing_key_label.wrap = true;
existing_key_label.wrap_mode = Pango.WrapMode.WORD_CHAR;
existing_key_label.xalign = 0;
var existing_key_page = new Gtk.Grid ();
existing_key_page.column_spacing = 12;

View file

@ -47,14 +47,19 @@ namespace Streamdeck.Views {
var command_title = new Gtk.Label (
_("Configure the command you wish send")
);
command_title.valign = Gtk.Align.CENTER;
command_title.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
command_title.hexpand = true;
command_title.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
command_title.max_width_chars = 75;
command_title.wrap = true;
command_title.wrap_mode = Pango.WrapMode.WORD_CHAR;
command_title.xalign = 0;
command_title.margin_bottom = 24;
var command_label = new Gtk.Label (
_("Command:")
);
command_label.halign = Gtk.Align.START;
command_label.valign = Gtk.Align.CENTER;
command_label.valign = Gtk.Align.START;
command_combobox = new Widgets.CommandComboBox ();
@ -84,8 +89,10 @@ namespace Streamdeck.Views {
}
column_spacing = 12;
row_spacing = 12;
row_spacing = 6;
halign = Gtk.Align.CENTER;
valign = Gtk.Align.CENTER;
vexpand = true;
margin = 24;
attach (command_title, 0, 0, 3);
@ -167,7 +174,7 @@ namespace Streamdeck.Views {
private void handle_scene_change (string scene_name) {
if (command != null && command.is_type (Data.CommandType.SWITCH_SCENE)) {
unowned var switch_scene = (Data.SwitchScene) command;
var switch_scene = (Data.SwitchScene) command;
switch_scene.scene_name = scene_name;
changed (command);
} else if (key != null) {

View file

@ -11,7 +11,8 @@ namespace Streamdeck.Views {
}
public void select_deck (string serial_number) {
if (get_child_by_name (serial_number) != null) {
var child = get_child_by_name (serial_number);
if (child != null) {
set_visible_child_name (serial_number);
}
}
@ -38,7 +39,7 @@ namespace Streamdeck.Views {
return;
}
unowned var list = (Widgets.CommandList) child;
var list = (Widgets.CommandList) child;
list.key_press (key_info);
}
@ -48,7 +49,7 @@ namespace Streamdeck.Views {
return;
}
unowned var list = (Widgets.CommandList) child;
var list = (Widgets.CommandList) child;
list.input_name_change (key, name);
}
@ -58,7 +59,7 @@ namespace Streamdeck.Views {
return;
}
unowned var list = (Widgets.CommandList) child;
var list = (Widgets.CommandList) child;
list.command_list (commands);
}
}

View file

@ -1,13 +1,11 @@
namespace Streamdeck.Views {
public class DeckView : Gtk.Grid {
private DeckStack deck_stack;
construct {
column_homogeneous = true;
column_spacing = 12;
row_spacing = 12;
deck_stack = new Views.DeckStack ();
DeckStack deck_stack = new Views.DeckStack ();
deck_stack.margin = 12;
deck_stack.margin_start = 0;

View file

@ -1,6 +1,6 @@
namespace Streamdeck.Views {
public class ObsView : Gtk.Stack {
private Gtk.EntryBuffer auth_buffer;
private Gtk.Entry auth_entry;
construct {
var base_grid = build_grid ();
@ -30,14 +30,12 @@ namespace Streamdeck.Views {
private void build_auth (Gtk.Grid grid) {
var auth_label = new Gtk.Label (_("Password:"));
var auth_entry = new Gtk.Entry ();
auth_entry = new Gtk.Entry ();
auth_entry.valign = Gtk.Align.CENTER;
auth_entry.set_visibility (false);
auth_entry.set_input_purpose (Gtk.InputPurpose.PASSWORD);
auth_entry.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
auth_buffer = auth_entry.get_buffer ();
grid.attach (auth_label, 0, 2);
grid.attach (auth_entry, 1, 2);
}
@ -48,8 +46,6 @@ namespace Streamdeck.Views {
host_entry.valign = Gtk.Align.CENTER;
host_entry.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
var host_buffer = host_entry.get_buffer ();
var port_label = new Gtk.Label (_("Port:"));
var port_entry = new Gtk.SpinButton.with_range (1, 65535, 1);
port_entry.valign = Gtk.Align.CENTER;
@ -57,7 +53,7 @@ namespace Streamdeck.Views {
App.obs_settings.bind (
"host",
host_buffer,
host_entry,
"text",
GLib.SettingsBindFlags.DEFAULT
);
@ -97,7 +93,7 @@ namespace Streamdeck.Views {
switch (state) {
case "Disconnected":
connect_button.label = _("Connect");
if (auth_buffer.length > 0) {
if (auth_entry.text.length > 0) {
set_visible_child_name ("auth-grid");
} else {
set_visible_child_name ("base-grid");
@ -108,7 +104,7 @@ namespace Streamdeck.Views {
set_visible_child_name ("auth-grid");
break;
default:
if (auth_buffer.length > 0) {
if (auth_entry.text.length > 0) {
set_visible_child_name ("auth-grid");
} else {
set_visible_child_name ("base-grid");
@ -122,25 +118,13 @@ namespace Streamdeck.Views {
connect_button.sensitive = false;
switch (Daemon.instance.get_obs_state ()) {
case "Disconnected":
Daemon.instance.connect_obs.begin ((_obj, res) => {
try {
Daemon.instance.connect_obs.end (res);
} catch (Error e) {
print ("Error connecting to obs: %s\n", e.message);
}
});
Daemon.instance.connect_obs.begin ();
break;
case "Unauthenticated":
Daemon.instance.authenticate_obs.begin (auth_buffer.text);
Daemon.instance.authenticate_obs.begin (auth_entry.text);
break;
default:
Daemon.instance.disconnect_obs.begin ((_obj, res) => {
try {
Daemon.instance.disconnect_obs.end (res);
} catch (Error e) {
print ("Error disconnecting from obs: %s\n", e.message);
}
});
Daemon.instance.disconnect_obs.begin ();
break;
}
});

View file

@ -78,7 +78,7 @@ namespace Streamdeck.Widgets {
return;
}
unowned var command_row = (CommandRow) row;
var command_row = (CommandRow) row;
var key = command_row.get_key ();
Daemon.instance.remove_command.begin (serial_number, key, (_obj, res) => {
@ -86,7 +86,9 @@ namespace Streamdeck.Widgets {
Daemon.instance.remove_command.end (res);
Daemon.instance.update_command_cache (serial_number);
print ("Widgets.CommandList unset");
row_map.unset (key);
print ("Widgets.CommandList after unset");
list_box.remove (row);
} catch (Error e) {
print ("Error removing command: %s\n", e.message);
@ -102,7 +104,7 @@ namespace Streamdeck.Widgets {
new_command_dialog.response.connect ((response_id) => {
if (response_id == Gtk.ResponseType.REJECT) {
unowned var app = (MainWindow) get_toplevel ();
var app = (MainWindow) get_toplevel ();
app.to_obs ();
}
@ -125,6 +127,9 @@ namespace Streamdeck.Widgets {
var existing = row_map.get (cmd_info.key);
if (existing != null) {
list_box.remove (existing);
print ("Widgets.CommandList unset");
row_map.unset (cmd_info.key);
print ("Widgets.CommandList after unset");
}
var name = Daemon.instance.get_input_name (serial_number, cmd_info.key);
@ -141,7 +146,7 @@ namespace Streamdeck.Widgets {
if (row == null) {
return;
}
unowned var command_row = (CommandRow) row;
var command_row = (CommandRow) row;
command_row.name_change (name);
}
}

View file

@ -102,7 +102,7 @@ namespace Streamdeck.Widgets {
}
private void switch_scene_ui (Gtk.Grid row_grid) {
unowned var switch_scene = (Data.SwitchScene) command;
var switch_scene = (Data.SwitchScene) command;
var to = new Gtk.Label (_("to"));
to.halign = Gtk.Align.START;
to.valign = Gtk.Align.CENTER;

View file

@ -42,7 +42,7 @@ namespace Streamdeck.Widgets {
}
row.activate ();
unowned var item = (DeckItem) row;
var item = (DeckItem) row;
deck_stack.select_deck (item.serial_number);
});
@ -57,12 +57,12 @@ namespace Streamdeck.Widgets {
deck_info.device_name = name;
}
foreach (unowned Gtk.Widget child in list_box.get_children ()) {
foreach (Gtk.Widget child in list_box.get_children ()) {
if (child == null) {
continue;
}
unowned var deck_item = (DeckItem) child;
var deck_item = (DeckItem) child;
already_present = already_present
|| deck_item.serial_number == deck_info.serial_number;
@ -84,12 +84,12 @@ namespace Streamdeck.Widgets {
}
public void remove_deck (DeckInfo deck_info) {
foreach (unowned Gtk.Widget child in list_box.get_children ()) {
foreach (Gtk.Widget child in list_box.get_children ()) {
if (child == null) {
continue;
}
unowned var deck_item = (DeckItem) child;
var deck_item = (DeckItem) child;
if (deck_item.serial_number == deck_info.serial_number) {
deck_stack.remove_deck (deck_info);
@ -103,12 +103,12 @@ namespace Streamdeck.Widgets {
}
private void handle_deck_name (string serial_number, string name) {
foreach (unowned Gtk.Widget row in list_box.get_children ()) {
foreach (Gtk.Widget row in list_box.get_children ()) {
if (row == null) {
continue;
}
unowned var item = (DeckItem) row;
var item = (DeckItem) row;
if (item.serial_number == serial_number) {
item.device_name = name;
}

View file

@ -1,18 +1,36 @@
namespace Streamdeck.Widgets {
public class DisconnectedPage : Gtk.Grid {
construct {
var disconnected_label = new Gtk.Label (
_("OBS is currently disconnected, try connecting it before configuring commands")
var title_label = new Gtk.Label (_("OBS is currently disconnected"));
title_label.hexpand = true;
title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
title_label.max_width_chars = 75;
title_label.wrap = true;
title_label.wrap_mode = Pango.WrapMode.WORD_CHAR;
title_label.xalign = 0;
var description_label = new Gtk.Label (
_("Try connecting it before configuring commands")
);
disconnected_label.valign = Gtk.Align.CENTER;
disconnected_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
description_label.hexpand = true;
description_label.max_width_chars = 75;
description_label.wrap = true;
description_label.use_markup = true;
description_label.xalign = 0;
description_label.valign = Gtk.Align.START;
column_spacing = 12;
row_spacing = 12;
halign = Gtk.Align.CENTER;
margin = 24;
var layout = new Gtk.Grid ();
layout.column_spacing = 12;
layout.row_spacing = 6;
layout.halign = Gtk.Align.CENTER;
layout.valign = Gtk.Align.CENTER;
layout.vexpand = true;
layout.margin = 24;
attach (disconnected_label, 0, 0);
layout.attach (title_label, 1, 1);
layout.attach (description_label, 1, 2);
add (layout);
show_all ();
}