Exemplo n.º 1
0
int
main(int argc, char **argv)
{
  GtkWidget *window, *revealer, *grid, *widget;
  GtkCssProvider *cssprovider;
  GError *error = NULL;
  guint x, y;

  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));
  g_option_context_add_group (context,
                              gtk_get_option_group (TRUE));

  if (!g_option_context_parse (context, &argc, &argv, &error))
    {
      g_printerr ("Option parsing failed: %s\n", error->message);
      return 1;
    }

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  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);
  gtk_container_add (GTK_CONTAINER (window), revealer);

  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (revealer), grid);

  cssprovider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }", -1, NULL);

  for (x = 0; x < 10; x++)
    {
      for (y = 0; y < 20; y++)
        {
          widget = gtk_label_new ("Hello World");
          gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
                                          GTK_STYLE_PROVIDER (cssprovider),
                                          GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
          gtk_grid_attach (GTK_GRID (grid), widget, x, y, 1, 1);
        }
    }

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
Exemplo n.º 2
0
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *scrolled_window;
  GtkWidget *viewport;
  GtkWidget *grid;
  GError *error = NULL;
  int i;

  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;
    }

  gtk_init ();

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  frame_stats_ensure (GTK_WINDOW (window));
  gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (window), scrolled_window);

  viewport = gtk_viewport_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scrolled_window), viewport);

  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (viewport), grid);

  for (i = 0; i < 4; i++)
    {
      GtkWidget *content = create_widget_factory_content ();
      gtk_grid_attach (GTK_GRID (grid), content,
                       i % 2, i / 2, 1, 1);
      g_object_unref (content);
    }

  gtk_widget_add_tick_callback (viewport,
                                scroll_viewport,
                                NULL,
                                NULL);

  gtk_widget_show (window);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);
  gtk_main ();

  return 0;
}
Exemplo n.º 3
0
int
main(int argc, char **argv)
{
  GError *error = NULL;
  GdkMonitor *monitor;
  GdkRectangle monitor_bounds;

  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));
  g_option_context_add_group (context,
                              gtk_get_option_group (TRUE));

  if (!g_option_context_parse (context, &argc, &argv, &error))
    {
      g_printerr ("Option parsing failed: %s\n", error->message);
      return 1;
    }

  g_print ("# Load factor: %g\n",
           load_factor);
  g_print ("# Resizing?: %s\n",
           cb_no_resize ? "no" : "yes");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  frame_stats_ensure (GTK_WINDOW (window));

  gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
  gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER);
  gtk_widget_set_app_paintable (window, TRUE);

  g_signal_connect (window, "draw",
                    G_CALLBACK (on_window_draw), NULL);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  g_signal_connect (window, "map-event",
                    G_CALLBACK (on_map_event), NULL);
  on_frame (0.);

  monitor = gdk_display_get_primary_monitor (gtk_widget_get_display (window));
  gdk_monitor_get_geometry (monitor, &monitor_bounds);

  gtk_window_move (GTK_WINDOW (window),
                   monitor_bounds.x + (monitor_bounds.width - window_width) / 2,
                   monitor_bounds.y + (monitor_bounds.height - window_height) / 2);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}