Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug: place contents in a Clamp #240

Merged
merged 2 commits into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/InputPanel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public class Sound.InputPanel : Gtk.Grid {
private InputDeviceMonitor device_monitor;

construct {
margin = 12;
margin_bottom = 24;
margin_top = 0;
margin_bottom = 12;
column_spacing = 12;
row_spacing = 6;

Expand Down
2 changes: 0 additions & 2 deletions src/OutputPanel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public class Sound.OutputPanel : Gtk.Grid {
public bool screen_reader_active { get; set; }

construct {
margin = 12;
margin_top = 0;
column_spacing = 12;
row_spacing = 6;

Expand Down
63 changes: 25 additions & 38 deletions src/Plug.vala
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
/*-
* Copyright (c) 2016-2017 elementary LLC. (https://elementary.io)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
/*
* SPDX-License-Identifier: LGPL-2.0-or-later
* SPDX-FileCopyrightText: 2016-2023 elementary, Inc. (https://elementary.io)
*
* Authored by: Corentin Noël <[email protected]>
*/

public class Sound.Plug : Switchboard.Plug {
Gtk.Grid main_grid;
Gtk.Stack stack;

InputPanel input_panel;
private Gtk.Box box;
private Gtk.Stack stack;
private InputPanel input_panel;

public Plug () {
GLib.Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
Expand All @@ -43,44 +27,47 @@ public class Sound.Plug : Switchboard.Plug {
}

public override Gtk.Widget get_widget () {
if (main_grid == null) {
if (box == null) {
var output_panel = new OutputPanel ();
input_panel = new InputPanel ();

stack = new Gtk.Stack () {
expand = true
hexpand = true,
vexpand = true
};
stack.add_titled (output_panel, "output", _("Output"));
stack.add_titled (input_panel, "input", _("Input"));

var stack_switcher = new Gtk.StackSwitcher () {
halign = Gtk.Align.CENTER,
homogeneous = true,
margin = 12,
stack = stack
};

stack.add_titled (output_panel, "output", _("Output"));
stack.add_titled (input_panel, "input", _("Input"));

stack.notify["visible-child"].connect (() => {
input_panel.set_visibility (stack.visible_child == input_panel);
});
var clamp = new Hdy.Clamp () {
child = stack
};

main_grid = new Gtk.Grid () {
orientation = Gtk.Orientation.VERTICAL
box = new Gtk.Box (VERTICAL, 12) {
margin = 12
};
main_grid.add (stack_switcher);
main_grid.add (stack);
main_grid.show_all ();
box.add (stack_switcher);
box.add (clamp);
box.show_all ();

var pam = PulseAudioManager.get_default ();
pam.start ();

stack.notify["visible-child"].connect (() => {
input_panel.set_visibility (stack.visible_child == input_panel);
});
}

return main_grid;
return box;
}

public override void shown () {
main_grid.show ();
box.show ();
if (stack.visible_child == input_panel) {
input_panel.set_visibility (true);
}
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ shared_module(
dependency('libpulse-mainloop-glib'),
dependency('libcanberra'),
dependency('libcanberra-gtk3'),
dependency('libhandy-1'),
meson.get_compiler('vala').find_library('libpulse-ext', dirs: join_paths(meson.source_root(), 'vapi')),
switchboard_dep
],
Expand Down