roster/src/widgets/environment_column_header.py

56 lines
1.9 KiB
Python

# environment_column_header.py
#
# Copyright 2025 Pavel Baksy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later
from gi.repository import Gtk, GObject
@Gtk.Template(resource_path='/cz/vesp/roster/widgets/environment-column-header.ui')
class EnvironmentColumnHeader(Gtk.Box):
"""Widget for displaying an environment column header with edit/delete buttons."""
__gtype_name__ = 'EnvironmentColumnHeader'
name_label = Gtk.Template.Child()
edit_button = Gtk.Template.Child()
delete_button = Gtk.Template.Child()
__gsignals__ = {
'edit-requested': (GObject.SIGNAL_RUN_FIRST, None, ()),
'delete-requested': (GObject.SIGNAL_RUN_FIRST, None, ()),
}
def __init__(self, environment):
super().__init__()
self.environment = environment
self.name_label.set_text(environment.name)
@Gtk.Template.Callback()
def on_edit_clicked(self, button):
"""Handle edit button click."""
self.emit('edit-requested')
@Gtk.Template.Callback()
def on_delete_clicked(self, button):
"""Handle delete button click."""
self.emit('delete-requested')
def update_name(self, name):
"""Update the environment name display."""
self.name_label.set_text(name)