Use headerbar for gtk153

This commit is contained in:
daleclack 2023-09-02 23:19:26 +08:00
parent 1ec62b07a8
commit 70a4984575
3 changed files with 25 additions and 3 deletions

View File

@ -8,7 +8,16 @@ struct _MyPrefs
G_DEFINE_TYPE(MyPrefs, my_prefs, GTK_TYPE_WINDOW)
static void my_prefs_init(MyPrefs *self)
{}
{
}
static void my_prefs_class_init(MyPrefsClass *klass)
{}
{
}
MyPrefs *my_prefs_new(GtkWindow *parent)
{
return MY_PREFS(g_object_new(my_prefs_get_type(),
"transient-for", parent, NULL));
}

View File

@ -3,3 +3,5 @@
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE(MyPrefs, my_prefs, MY, PREFS, GtkWindow)
MyPrefs *my_prefs_new(GtkWindow *parent);

View File

@ -13,6 +13,7 @@ struct _MyReminder
{
GtkApplicationWindow parent_instance;
GtkWidget *time_label;
GtkWidget *header, *btn_prefs;
int year, month, day;
std::string color;
};
@ -66,8 +67,18 @@ static void my_reminder_init(MyReminder *self)
{
// Set properties of window
gtk_window_set_icon_name(GTK_WINDOW(self), "org.gtk.daleclack");
gtk_window_set_default_size(GTK_WINDOW(self), 240, 200);
gtk_window_set_default_size(GTK_WINDOW(self), 350, 250);
gtk_window_set_title(GTK_WINDOW(self), "Reminder");
// Create header bar
self->header = gtk_header_bar_new();
gtk_header_bar_set_decoration_layout(GTK_HEADER_BAR(self->header),
"close,minimize,maximize,icon:menu");
gtk_window_set_titlebar(GTK_WINDOW(self), self->header);
// Create button for preference
self->btn_prefs = gtk_button_new_with_label("Prefs");
gtk_header_bar_pack_end(GTK_HEADER_BAR(self->header), self->btn_prefs);
// Load data from json file
load_json_data(self);