Update custom title bar

This commit is contained in:
daleclack 2024-03-28 21:21:41 +08:00
parent 4501c1903b
commit b81414180b
4 changed files with 12 additions and 3 deletions

View File

@ -108,7 +108,7 @@ static void calc_app_init(CalcApp *self)
self->title_bar = my_titlebar_new();
gtk_window_set_title(GTK_WINDOW(self), "Calculator");
gtk_window_set_icon_name(GTK_WINDOW(self), "calcapp");
my_titlebar_set_window(self->title_bar, GTK_WIDGET(self));
my_titlebar_set_window(self->title_bar, self);
// Link Signals
g_signal_connect(self->btnanswer, "clicked", G_CALLBACK(btnanswer_clicked), self);

View File

@ -1,6 +1,7 @@
#include "DrawApp.h"
#include "MyFinder.h"
#include "MyLimit.h"
#include "MyTitleBar.h"
typedef enum
{
@ -21,6 +22,9 @@ struct _DrawApp
{
GtkWindow parent_instance;
// Custom Title Bar
MyTitleBar *title_bar;
// Child widgets
GtkWidget *draw_area;
GtkWidget *fill_check;
@ -289,6 +293,8 @@ static void draw_app_init(DrawApp *self)
// Initalize window
gtk_window_set_title(GTK_WINDOW(self), "Drawing App");
gtk_window_set_icon_name(GTK_WINDOW(self), "drawing_app");
self->title_bar = my_titlebar_new();
my_titlebar_set_window(self->title_bar, self);
// gtk_window_set_default_size(GTK_WINDOW(self), 640, 480);
// Create widgets

View File

@ -20,7 +20,7 @@ static void ctrl_win_close(MyTitleBar *self)
gtk_window_close(GTK_WINDOW(self->ctrl_window));
}
void my_titlebar_set_window(MyTitleBar *self, GtkWidget *window)
void _my_titlebar_set_window(MyTitleBar *self, GtkWidget *window)
{
gtk_window_set_titlebar(GTK_WINDOW(window), self->header);
self->ctrl_window = window;

View File

@ -2,8 +2,11 @@
#include <gtk/gtk.h>
#define my_titlebar_set_window(title_bar, window) \
_my_titlebar_set_window(My_TitleBar(title_bar), GTK_WIDGET(window))
G_DECLARE_FINAL_TYPE(MyTitleBar, my_titlebar, My, TitleBar, GObject)
void my_titlebar_set_window(MyTitleBar *title_bar, GtkWidget *window);
void _my_titlebar_set_window(MyTitleBar *title_bar, GtkWidget *window);
MyTitleBar *my_titlebar_new();