Notifications fonctionnelles
This commit is contained in:
parent
70348674cd
commit
0a494a6b21
|
@ -101,6 +101,10 @@ void on_savefile_action(GSimpleAction *action,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
void on_toast_close_action(GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
static const GActionEntry app_actions[] = {
|
static const GActionEntry app_actions[] = {
|
||||||
{ "quit", on_quit_action, NULL, NULL, NULL },
|
{ "quit", on_quit_action, NULL, NULL, NULL },
|
||||||
|
@ -113,6 +117,7 @@ static const GActionEntry app_actions[] = {
|
||||||
{ "openfile", on_openfile_action, NULL, NULL, NULL },
|
{ "openfile", on_openfile_action, NULL, NULL, NULL },
|
||||||
{ "closefile", on_closefile_action, NULL, NULL, NULL },
|
{ "closefile", on_closefile_action, NULL, NULL, NULL },
|
||||||
{ "savefile", on_savefile_action, NULL, NULL, NULL },
|
{ "savefile", on_savefile_action, NULL, NULL, NULL },
|
||||||
|
{ "toastclose", on_toast_close_action, NULL, NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
void ui_enable_action(const char *name);
|
void ui_enable_action(const char *name);
|
||||||
|
@ -140,3 +145,4 @@ void ui_set_stack(const char *mode);
|
||||||
|
|
||||||
void ui_send_notification(const char *message);
|
void ui_send_notification(const char *message);
|
||||||
void ui_send_internal_notification(const char *message);
|
void ui_send_internal_notification(const char *message);
|
||||||
|
void ui_close_internal_notification(void);
|
||||||
|
|
|
@ -69,7 +69,7 @@ void on_preferences_action(GSimpleAction *action,
|
||||||
|
|
||||||
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
||||||
|
|
||||||
ui_send_notification("Not implemented !");
|
ui_send_internal_notification("Not implemented !");
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_togglesidebar_action(GSimpleAction *action,
|
void on_togglesidebar_action(GSimpleAction *action,
|
||||||
|
@ -80,7 +80,7 @@ void on_togglesidebar_action(GSimpleAction *action,
|
||||||
|
|
||||||
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
||||||
|
|
||||||
ui_send_notification("Not implemented !");
|
ui_send_internal_notification("Not implemented !");
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_editmode_action(GSimpleAction *action,
|
void on_editmode_action(GSimpleAction *action,
|
||||||
|
@ -170,6 +170,17 @@ void on_savefile_action(GSimpleAction *action,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void on_toast_close_action(GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GemGraphClientApplication *self = user_data;
|
||||||
|
|
||||||
|
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
||||||
|
|
||||||
|
ui_close_internal_notification();
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -162,33 +162,22 @@
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box2">
|
<object class="GtkBox" id="toast_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<property name="spacing">20</property>
|
<property name="spacing">20</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label2">
|
<object class="GtkLabel" id="toast_text">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">This is an app-notification. Click the button to dismiss</property>
|
<property name="label" translatable="yes">(null)</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="toast_close_button">
|
<object class="GtkToggleButton" id="toast_close_button">
|
||||||
<property name="visible">True</property>
|
<property name="icon-name">window-close-symbolic</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="action-name">app.toastclose</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -207,7 +207,8 @@ struct _GemGraphClientWindow
|
||||||
GtkMenuButton *main_button_mode;
|
GtkMenuButton *main_button_mode;
|
||||||
GtkToggleButton *main_button_sidebar;
|
GtkToggleButton *main_button_sidebar;
|
||||||
GtkRevealer *toast_revealer;
|
GtkRevealer *toast_revealer;
|
||||||
GtkButton *toast_close_button;
|
GtkToggleButton *toast_close_button;
|
||||||
|
GtkLabel *toast_text;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_FINAL_TYPE (GemGraphClientWindow,
|
G_DEFINE_FINAL_TYPE (GemGraphClientWindow,
|
||||||
|
@ -253,6 +254,9 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass)
|
||||||
gtk_widget_class_bind_template_child(widget_class,
|
gtk_widget_class_bind_template_child(widget_class,
|
||||||
GemGraphClientWindow,
|
GemGraphClientWindow,
|
||||||
toast_close_button);
|
toast_close_button);
|
||||||
|
gtk_widget_class_bind_template_child(widget_class,
|
||||||
|
GemGraphClientWindow,
|
||||||
|
toast_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gem_graph_client_window_init(GemGraphClientWindow *self)
|
static void gem_graph_client_window_init(GemGraphClientWindow *self)
|
||||||
|
@ -312,6 +316,26 @@ void ui_send_internal_notification(const char *message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gtk_overlay_add_overlay(self->toast_overlay, //XXX);
|
if (window->toast_text == NULL) {
|
||||||
g_print("NOTIFICATION: %s\n", message);
|
g_printerr("Can't find self->toast_overlay !\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_label_set_label(window->toast_text, message);
|
||||||
|
gtk_revealer_set_reveal_child(window->toast_revealer, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_close_internal_notification(void)
|
||||||
|
{
|
||||||
|
if (window->toast_revealer == NULL) {
|
||||||
|
g_printerr("Can't find self->toast_overlay !\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->toast_text == NULL) {
|
||||||
|
g_printerr("Can't find self->toast_overlay !\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_revealer_set_reveal_child(window->toast_revealer, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue