Skip to content

Commit

Permalink
(core): Improve Board dialog implementation
Browse files Browse the repository at this point in the history
* Properly use AdwDialog UI builder
* Remove can-close=false workaround to be able to close dialogs using adw_dialog_force_close
  • Loading branch information
smolBlackCat committed Dec 25, 2024
1 parent 636e6cf commit d677691
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 69 deletions.
9 changes: 5 additions & 4 deletions src/dialog/create_board_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
#include <glibmm/i18n.h>
#include <utils.h>

#include <iostream>

namespace ui {
CreateBoardDialog::CreateBoardDialog(ProgressWindow& board_creator)
: BoardDialog{}, board_creator{board_creator} {}
: BoardDialog{}, board_creator{board_creator} {
adw_dialog_set_title(ADW_DIALOG(board_dialog->gobj()),
_("Create New Board"));
}

CreateBoardDialog* CreateBoardDialog::create(ProgressWindow& board_creator) {
return new CreateBoardDialog(board_creator);
Expand Down Expand Up @@ -52,6 +53,6 @@ void CreateBoardDialog::create_board() {
}

board_creator.add_local_board(backend);
close();
adw_dialog_close(ADW_DIALOG(board_dialog->gobj()));
}
} // namespace ui
6 changes: 4 additions & 2 deletions src/dialog/preferences-board-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

#include <filesystem>

#include "gtkmm/messagedialog.h"
#include "adwaita.h"

namespace ui {

PreferencesBoardDialog::PreferencesBoardDialog(BoardWidget& board_widget)
: BoardDialog{}, board_widget{board_widget} {
adw_dialog_set_title(ADW_DIALOG(board_dialog->gobj()),
_("Board Preferences"));
footer_button->set_label(_("Save"));
load_board();
}
Expand Down Expand Up @@ -87,6 +89,6 @@ void PreferencesBoardDialog::on_save_changes() {
}

board_widget.save(false);
close();
adw_dialog_close(ADW_DIALOG(board_dialog->gobj()));
}
} // namespace ui
150 changes: 87 additions & 63 deletions src/resources/ui/board-dialog.ui
Original file line number Diff line number Diff line change
@@ -1,73 +1,97 @@
<?xml version='1.0' encoding='UTF-8'?>
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Created with Cambalache 0.92.1 -->
<interface>
<!-- interface-name board-dialog.ui -->
<requires lib="gio" version="2.0"/>
<requires lib="gtk" version="4.12"/>
<requires lib="libadwaita" version="1.5"/>
<requires lib="gio" version="2.0" />
<requires lib="gtk" version="4.12" />
<requires lib="libadwaita" version="1.5" />
<object class="AdwDialog" id="board-dialog">
<property name="can-close">False</property>
<property name="child">
<object class="GtkBox">
<property name="margin-bottom">15</property>
<property name="margin-end">15</property>
<property name="margin-start">15</property>
<property name="margin-top">15</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="css-classes">title-4</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Board Title</property>
</object>
</child>
<child>
<object class="GtkEntry" id="board-title-entry"/>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="css-classes">title-4</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Board Background</property>
</object>
<property name="can-close">True</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" />
</child>
<child>
<object class="GtkMenuButton" id="background-setter-menubutton">
<property name="child">
<object class="GtkPicture" id="board-picture">
<property name="content-fit">cover</property>
<property name="css-classes">frame</property>
<property name="margin-bottom">10</property>
<property name="margin-top">10</property>
</object>
</property>
<property name="direction">right</property>
<property name="menu-model">bg-setter-menu-model</property>
<property name="tooltip-text" translatable="yes">Click to set a board background</property>
<property name="vexpand">True</property>
</object>
<object class="GtkBox">
<property name="margin-bottom">15</property>
<property name="margin-end">15</property>
<property name="margin-start">15</property>
<property name="margin-top">15</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="css-classes">title-4</property>
<property name="halign">start</property>
<property
name="label"
translatable="yes"
>Board Title</property>
</object>
</child>
<child>
<object class="GtkEntry" id="board-title-entry" />
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="css-classes">title-4</property>
<property name="halign">start</property>
<property
name="label"
translatable="yes"
>Board Background</property>
</object>
</child>
<child>
<object
class="GtkMenuButton"
id="background-setter-menubutton"
>
<property name="child">
<object class="GtkPicture" id="board-picture">
<property name="content-fit">cover</property>
<property name="css-classes">frame</property>
<property name="margin-bottom">10</property>
<property name="margin-top">10</property>
</object>
</property>
<property name="direction">right</property>
<property
name="menu-model"
>bg-setter-menu-model</property>
<property
name="tooltip-text"
translatable="yes"
>Click to set a board background</property>
<property name="vexpand">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="footer-button">
<property name="css-classes">suggested-action</property>
<property
name="label"
translatable="yes"
>Create Board</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="footer-button">
<property name="css-classes">suggested-action</property>
<property name="label" translatable="yes">Create Board</property>
</object>
</child>
</object>
</property>
</object>
</child>
<property name="content-height">450</property>
<property name="content-width">400</property>
</object>
Expand Down

0 comments on commit d677691

Please sign in to comment.