Skip to content

Commit

Permalink
Impl better main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Feb 10, 2024
1 parent f122ad1 commit 1339816
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 67 deletions.
1 change: 1 addition & 0 deletions data/io.github.lainsce.Notejot.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<file alias="edit_notebooks.ui">ui/edit_notebooks.ui</file>
<file alias="move_to_dialog.ui">ui/move_to_dialog.ui</file>
<file alias="main_window.ui">ui/main_window.ui</file>
<file alias="main_menu.ui">ui/main_menu.ui</file>
<file alias="note_theme.ui">ui/note_theme.ui</file>
<file alias="notecontentview.ui">ui/notecontentview.ui</file>
<file alias="notelistview.ui">ui/notelistview.ui</file>
Expand Down
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ blueprints = custom_target(
'blueprints',
input: files(
'ui/edit_notebooks.blp',
'ui/main_menu.blp',
'ui/move_to_dialog.blp',
'ui/note_theme.blp',
'ui/notebooklistview.blp',
Expand Down
60 changes: 60 additions & 0 deletions data/ui/main_menu.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Gtk 4.0;
using He 1;

template $NotejotWidgetsMainMenu : Box {
orientation: vertical;
styles [
"notejot-theme",
]

Box {
orientation: vertical;
spacing: 6;
margin-start: 6;
margin-end: 10;

Label {
label: _('Font Size');
halign: start;
styles [
"caption",
"dim-label",
]
}

He.SegmentedButton {
ToggleButton s {
label: 'Small';
action-name: 'app.font-size';
action-target: '"\'small\'"';
}

ToggleButton {
label: 'Medium';
action-name: 'app.font-size';
action-target: '"\'medium\'"';
group: s;
}

ToggleButton {
label: 'Large';
action-name: 'app.font-size';
action-target: '"\'large\'"';
group: s;
}
}
}

He.Divider {
}

He.TextButton about_button {
hexpand: true;
action-name: 'win.action_about';
child:
He.ButtonContent {
icon: "dialog-information-symbolic";
label: _("About Notejot");
};
}
}
64 changes: 2 additions & 62 deletions data/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
<interface>
<menu id="menu">
<item>
<attribute name="label" translatable="yes">Text size</attribute>
<attribute name="display-hint">inline-buttons</attribute>
<attribute name="custom">zoom-grid</attribute>
<attribute name="custom">zoom</attribute>
</item>
<section>
<item>
<attribute name="label" translatable="yes">About Notejot</attribute>
<attribute name="action">win.action_about</attribute>
</item>
</section>
</menu>
<template class="NotejotMainWindow" parent="HeApplicationWindow">
<property name="visible">1</property>
Expand Down Expand Up @@ -51,59 +43,7 @@
<child type="titlebar-button">
<object class="GtkMenuButton" id="menu_button">
<property name="icon-name">open-menu-symbolic</property>
<property name="popover">
<object class="GtkPopoverMenu">
<property name="menu-model">menu</property>
<child type="zoom-grid">
<object class="GtkBox">
<property name="hexpand">1</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="margin-start">10</property>
<property name="margin-end">6</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="true">Font Size</property>
<property name="sensitive">0</property>
</object>
</child>
</object>
</child>
<child>
<object class="HeSegmentedButton">
<child>
<object class="GtkToggleButton" id="s">
<property name="label">Small</property>
<property name="action-name">app.font-size</property>
<property name="action-target">"'small'"</property>
</object>
</child>
<child>
<object class="GtkToggleButton">
<property name="label">Medium</property>
<property name="action-name">app.font-size</property>
<property name="action-target">"'medium'"</property>
<property name="group">s</property>
</object>
</child>
<child>
<object class="GtkToggleButton">
<property name="label">Large</property>
<property name="action-name">app.font-size</property>
<property name="action-target">"'large'"</property>
<property name="group">s</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
<property name="menu-model">menu</property>
</object>
</child>
<child>
Expand Down
7 changes: 4 additions & 3 deletions data/ui/note_theme.blp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ template $NotejotWidgetsNoteTheme : Box {
]

Label {
margin-start: 8;
margin-bottom: 6;
margin-start: 6;
margin-end: 10;
halign: start;
label: _("Note Color");

styles [
"caption",
"dim-label",
]
}
Expand All @@ -23,7 +24,7 @@ template $NotejotWidgetsNoteTheme : Box {
column-spacing: 6;
row-spacing: 6;
margin-start: 6;
margin-end: 6;
margin-end: 10;
hexpand: true;

CheckButton color_button_red {
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ sources = [
'src/Views/TrashContentView.vala',
'src/Views/TrashListView.vala',
'src/Views/View.vala',
'src/Widgets/EditNotebookDialog.vala',\
'src/Widgets/EditNotebookDialog.vala',
'src/Widgets/MainMenu.vala',
'src/Widgets/NotebookMainRowContent.vala',
'src/Widgets/NoteRowContent.vala',
'src/Widgets/MoveToDialog.vala',
Expand Down
10 changes: 9 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ namespace Notejot {
this.mw = (MainWindow) app.get_active_window ();
this.album = albumt;

menu_button.get_popover ().has_arrow = false;
// Main Menu
var nmp = new Widgets.MainMenu ();
var pop = (Gtk.PopoverMenu)menu_button.get_popover ();
pop.add_child (nmp, "zoom");
pop.has_arrow = false;

nmp.about_button.clicked.connect (() => {
pop.closed ();
});
}

protected override bool close_request () {
Expand Down
25 changes: 25 additions & 0 deletions src/Widgets/MainMenu.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2017-2022 Lains
*
* 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 2 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Notejot {
[GtkTemplate (ui = "/io/github/lainsce/Notejot/main_menu.ui")]
public class Widgets.MainMenu : Gtk.Box {
[GtkChild]
public unowned He.TextButton about_button;
}
}

0 comments on commit 1339816

Please sign in to comment.