Score:0

Adding gtk3 accelerators in C

US flag
user1711651

I'm trying to implement accelerators in gtk3 for my app. I found out how to do it from a post on github.

#include <stdio.h>
#include <gtk/gtk.h>

// This is a callback that will be called when the accelerator is
// pressed.
void accelerator_pressed(void)
{
    printf("accelerator_pressed\n");
}

int main(int argc, char** argv)
{
    gtk_init(&argc, &argv);

    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    GClosure* closure = g_cclosure_new(accelerator_pressed, 0, 0);

    // Set up the accelerator group.
    GtkAccelGroup* accel_group = gtk_accel_group_new();
    gtk_accel_group_connect(accel_group,
                            GDK_KEY_A,
                            GDK_CONTROL_MASK,
                            0,
                            closure);
    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

    // Quit the app when the window is closed.
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    // Display the top level window.
    gtk_widget_show(window);

    gtk_main();

    return 0;
}

My question is how to implement it without creating a window.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.