forked from AuroraMiddleware/gtk
Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master See merge request GNOME/gtk!2735
This commit is contained in:
commit
6ce2e19bbe
@ -586,53 +586,53 @@ print_hello (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget, gpointer data)
|
||||
quit_cb (GtkWindow *window)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
gtk_window_close (window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
static void
|
||||
activate (GtkApplication *app,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GObject *window;
|
||||
GObject *button;
|
||||
gboolean done = FALSE;
|
||||
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
gtk_init ();
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
builder = gtk_builder_new ();
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (builder, "builder.ui", NULL);
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object (builder, "window");
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
GObject *window = gtk_builder_get_object (builder, "window");
|
||||
gtk_window_set_application (GTK_WINDOW (window), app);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button1");
|
||||
GObject *button = gtk_builder_get_object (builder, "button1");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button2");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "quit");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
/* We do not need the builder any more */
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||
|
||||
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
return status;
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -71,12 +71,12 @@ the question you have, this list is a good place to start.
|
||||
6. How do I use GTK with threads?
|
||||
|
||||
GTK requires that all GTK API calls are made from the same thread in which
|
||||
gtk_init() was called (the _main thread_).
|
||||
the #GtkApplication was created, or gtk_init() was called (the _main thread_).
|
||||
|
||||
If you want to take advantage of multi-threading in a GTK application,
|
||||
it is usually best to send long-running tasks to worker threads, and feed
|
||||
the results back to the main thread using g_idle_add() or GAsyncQueue. GIO
|
||||
offers useful tools for such an approach such as GTask.
|
||||
the results back to the main thread using g_idle_add() or #GAsyncQueue. GIO
|
||||
offers useful tools for such an approach such as #GTask.
|
||||
|
||||
7. How do I internationalize a GTK program?
|
||||
|
||||
|
@ -11,49 +11,49 @@ print_hello (GtkWidget *widget,
|
||||
static void
|
||||
quit_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gboolean *done = data;
|
||||
GtkWindow *window = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
gtk_window_close (window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
static void
|
||||
activate (GtkApplication *app,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GObject *window;
|
||||
GObject *button;
|
||||
gboolean done = FALSE;
|
||||
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
gtk_init ();
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
builder = gtk_builder_new ();
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (builder, "builder.ui", NULL);
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object (builder, "window");
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
GObject *window = gtk_builder_get_object (builder, "window");
|
||||
gtk_window_set_application (GTK_WINDOW (window), app);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button1");
|
||||
GObject *button = gtk_builder_get_object (builder, "button1");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button2");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "quit");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
return 0;
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||
|
||||
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user