2014-09-29 21:10:41 +00:00
|
|
|
/* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "frame-stats.h"
|
|
|
|
|
|
|
|
double reveal_time = 5;
|
|
|
|
|
|
|
|
static GOptionEntry options[] = {
|
|
|
|
{ "time", 't', 0, G_OPTION_ARG_DOUBLE, &reveal_time, "Reveal time", "SECONDS" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
toggle_reveal (GtkRevealer *revealer)
|
|
|
|
{
|
|
|
|
gtk_revealer_set_reveal_child (revealer, !gtk_revealer_get_reveal_child (revealer));
|
|
|
|
}
|
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
static void
|
|
|
|
quit_cb (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *done = data;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
|
|
|
|
g_main_context_wakeup (NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-29 21:10:41 +00:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
GtkWidget *window, *revealer, *grid, *widget;
|
|
|
|
GtkCssProvider *cssprovider;
|
|
|
|
GError *error = NULL;
|
|
|
|
guint x, y;
|
2020-02-10 03:24:47 +00:00
|
|
|
gboolean done = FALSE;
|
2014-09-29 21:10:41 +00:00
|
|
|
|
|
|
|
GOptionContext *context = g_option_context_new (NULL);
|
|
|
|
g_option_context_add_main_entries (context, options, NULL);
|
|
|
|
frame_stats_add_options (g_option_context_get_main_group (context));
|
|
|
|
|
|
|
|
if (!g_option_context_parse (context, &argc, &argv, &error))
|
|
|
|
{
|
|
|
|
g_printerr ("Option parsing failed: %s\n", error->message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
|
|
|
|
2020-02-14 19:55:36 +00:00
|
|
|
window = gtk_window_new ();
|
2020-02-10 03:24:47 +00:00
|
|
|
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
2014-09-29 21:10:41 +00:00
|
|
|
frame_stats_ensure (GTK_WINDOW (window));
|
|
|
|
|
|
|
|
revealer = gtk_revealer_new ();
|
|
|
|
gtk_widget_set_valign (revealer, GTK_ALIGN_START);
|
|
|
|
gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
|
|
|
|
gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), reveal_time * 1000);
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
|
|
|
|
g_signal_connect_after (revealer, "map", G_CALLBACK (toggle_reveal), NULL);
|
|
|
|
g_signal_connect_after (revealer, "notify::child-revealed", G_CALLBACK (toggle_reveal), NULL);
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (window), revealer);
|
2014-09-29 21:10:41 +00:00
|
|
|
|
|
|
|
grid = gtk_grid_new ();
|
2020-05-02 21:02:42 +00:00
|
|
|
gtk_revealer_set_child (GTK_REVEALER (revealer), grid);
|
2014-09-29 21:10:41 +00:00
|
|
|
|
|
|
|
cssprovider = gtk_css_provider_new ();
|
2016-10-17 14:09:12 +00:00
|
|
|
gtk_css_provider_load_from_data (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }", -1);
|
2020-02-08 02:32:21 +00:00
|
|
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
|
|
|
GTK_STYLE_PROVIDER (cssprovider),
|
|
|
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
2014-09-29 21:10:41 +00:00
|
|
|
|
|
|
|
for (x = 0; x < 10; x++)
|
|
|
|
{
|
|
|
|
for (y = 0; y < 20; y++)
|
|
|
|
{
|
|
|
|
widget = gtk_label_new ("Hello World");
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), widget, x, y, 1, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2014-09-29 21:10:41 +00:00
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
while (!done)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2014-09-29 21:10:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|