Commit b6b38266 authored by Zander Brown's avatar Zander Brown Committed by Zander Brown

add completion notifications

parent cffd9d9c
......@@ -28,7 +28,7 @@ We also considered a center aligned ~ to be a proper station roundel but we felt
- [ ] 'API' compatible with GNOME Terminal
- [ ] Command line flags *Partial, supports -e/--command and --working-directory*
- [ ] Command done notifications
- [X] Command done notifications
- [X] 'root mode' turns red when sudo/su/pkexec is active in the terminal
- [X] 'remote mode' turns (purple?) when ssh is in use
- [ ] Other bash/shell integrations
......
......@@ -552,11 +552,35 @@ static GOptionEntry entries[] =
{ NULL }
};
static void
focus_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
KgxApplication *self = KGX_APPLICATION (data);
GtkWindow *win;
win = gtk_application_get_window_by_id (GTK_APPLICATION (self),
g_variant_get_uint32 (parameter));
gtk_window_present_with_time (win, GDK_CURRENT_TIME);
}
static GActionEntry app_entries[] =
{
{ "focus-window", focus_activated, "u", NULL, NULL },
};
static void
kgx_application_init (KgxApplication *self)
{
g_application_add_main_option_entries (G_APPLICATION (self), entries);
g_action_map_add_action_entries (G_ACTION_MAP (self),
app_entries,
G_N_ELEMENTS (app_entries),
self);
self->desktop_interface = g_settings_new (DESKTOP_INTERFACE_SETTINGS_SCHEMA);
g_signal_connect (self->desktop_interface,
......
......@@ -229,6 +229,11 @@ kgx_window_constructed (GObject *object)
g_auto (GStrv) shell = NULL;
g_auto (GStrv) env = NULL;
g_autofree char *command = NULL;
guint id = 0;
id = gtk_application_window_get_id (GTK_APPLICATION_WINDOW (self));
self->notification_id = g_strdup_printf ("command-completed-%u", id);
pty = vte_pty_new_sync (fp_vte_pty_default_flags (), NULL, &error);
......@@ -334,9 +339,14 @@ static void
kgx_window_finalize (GObject *object)
{
KgxWindow *self = KGX_WINDOW (object);
GtkApplication *app = gtk_window_get_application (GTK_WINDOW (self));
g_application_withdraw_notification (G_APPLICATION (app),
self->notification_id);
g_clear_pointer (&self->working_dir, g_free);
g_clear_pointer (&self->command, g_free);
g_clear_pointer (&self->notification_id, g_free);
g_clear_pointer (&self->root, g_hash_table_unref);
g_clear_pointer (&self->remote, g_hash_table_unref);
......@@ -983,6 +993,7 @@ kgx_window_pop_child (KgxWindow *self,
{
GtkStyleContext *context;
GPid pid = 0;
guint id = 0;
g_return_if_fail (KGX_IS_WINDOW (self));
......@@ -994,4 +1005,23 @@ kgx_window_pop_child (KgxWindow *self,
pop_type (self->remote, pid, context, KGX_WINDOW_STYLE_REMOTE);
pop_type (self->root, pid, context, KGX_WINDOW_STYLE_ROOT);
pop_type (self->children, pid, context, NULL);
if (!gtk_window_is_active (GTK_WINDOW (self))) {
g_autoptr (GNotification) noti = NULL;
GtkApplication *app = gtk_window_get_application (GTK_WINDOW (self));
noti = g_notification_new (_("Command complete"));
#if HAS_GTOP
g_notification_set_body (noti, kgx_process_get_exec (process));
#endif
id = gtk_application_window_get_id (GTK_APPLICATION_WINDOW (self));
g_notification_set_default_action_and_target (noti,
"app.focus-window",
"u",
id);
g_application_send_notification (G_APPLICATION (app),
self->notification_id,
noti);
}
}
......@@ -83,6 +83,8 @@ struct _KgxWindow
GtkWidget *exit_info;
GtkWidget *exit_message;
GtkWidget *zoom_level;
char *notification_id;
};
G_DECLARE_FINAL_TYPE (KgxWindow, kgx_window, KGX, WINDOW, GtkApplicationWindow)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment