WIP: Notification widget

This commit is contained in:
Adrien Bourmault 2023-01-25 20:48:36 +01:00
parent a70d4fcf21
commit 9f3cb07837
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
2 changed files with 52 additions and 5 deletions

View File

@ -46,7 +46,7 @@
</child> </child>
<child> <child>
<object class="GtkOverlay" id="toast_overlay"> <object class="GtkOverlay" id="toast_overlay">
<property name="child"> <child>
<object class="GtkPaned" id="main_paned"> <object class="GtkPaned" id="main_paned">
<property name="position">300</property> <property name="position">300</property>
<child> <child>
@ -154,7 +154,50 @@
</object> </object>
</child> </child>
</object> </object>
</property> </child>
<child type="overlay">
<object class="GtkRevealer" id="toast_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="spacing">20</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This is an app-notification. Click the button to dismiss</property>
</object>
</child>
<child>
<object class="GtkButton" id="toast_close_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close-symbolic</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
</child>
<style>
<class name="app-notification"/>
</style>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</template> </template>

View File

@ -206,7 +206,8 @@ struct _GemGraphClientWindow
GtkPaned *main_paned; GtkPaned *main_paned;
GtkMenuButton *main_button_mode; GtkMenuButton *main_button_mode;
GtkToggleButton *main_button_sidebar; GtkToggleButton *main_button_sidebar;
GtkOverlay *toast_overlay; GtkRevealer *toast_revealer;
GtkButton *toast_close_button;
}; };
G_DEFINE_FINAL_TYPE (GemGraphClientWindow, G_DEFINE_FINAL_TYPE (GemGraphClientWindow,
@ -248,7 +249,10 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass)
main_button_sidebar); main_button_sidebar);
gtk_widget_class_bind_template_child(widget_class, gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow, GemGraphClientWindow,
toast_overlay); toast_revealer);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
toast_close_button);
} }
static void gem_graph_client_window_init(GemGraphClientWindow *self) static void gem_graph_client_window_init(GemGraphClientWindow *self)
@ -303,7 +307,7 @@ void ui_set_stack(const char *mode)
void ui_send_internal_notification(const char *message) void ui_send_internal_notification(const char *message)
{ {
if (window->toast_overlay == NULL) { if (window->toast_revealer == NULL) {
g_printerr("Can't find self->toast_overlay !\n"); g_printerr("Can't find self->toast_overlay !\n");
return; return;
} }