Exemple #1
0
Fichier : main.c Projet : plean/CPE
int		main(int ac, char **av)
{
  t_struct	a;

  if (init_tabl(&a))
    return (0);
  a.k = 0;
  a.music = NULL;
  a.back = (ac > 1) ? bunny_load_pixelarray(av[1]) :
      bunny_load_pixelarray("img/carré2.png");
  a.lettre = bunny_load_pixelarray("img/nombres.png");
  if (a.lettre == NULL || a.back == NULL)
    return (0);
  a.square = bunny_new_pixelarray(SQUARE_SIZE, SQUARE_SIZE);
  fox_mod_stretch(a.square, a.back);
  a.nb = bunny_new_pixelarray(SQUARE_SIZE * 9, SQUARE_SIZE);
  fox_mod_stretch(a.nb, a.lettre);
  a.win = bunny_start_style(SQUARE_SIZE * 9 + ECART * 2,
			    SQUARE_SIZE * 9 + ECART * 2,
			    TITLEBAR | CLOSE_BUTTON, "Sudoku");
  a.pix = bunny_new_pixelarray(SQUARE_SIZE * 9 + ECART * 2,
			       SQUARE_SIZE * 9 + ECART * 2);
  destroy_windows(a);
  return (0);
}
static void
on_name_lost  (GDBusConnection *connection,
	       const gchar     *name,
	       gpointer         user_data)
{
  destroy_windows ();
  gtk_main_quit ();
}
static gboolean
on_timeout (gpointer data)
{
  timeout_id = 0;

  destroy_windows ();
  gtk_main_quit ();

  return FALSE;
}
static void
handle_method_call (GDBusConnection       *connection,
		    const gchar           *sender,
		    const gchar           *object_path,
		    const gchar           *interface_name,
		    const gchar           *method_name,
		    GVariant              *parameters,
		    GDBusMethodInvocation *invocation,
		    gpointer               user_data)
{
  /* Push off the idle timeout */
  establish_timeout ();

  if (g_strcmp0 (method_name, "Exit") == 0)
    {
      destroy_windows ();

      g_dbus_method_invocation_return_value (invocation, NULL);
      g_dbus_connection_flush_sync (connection, NULL, NULL);

      gtk_main_quit ();
    }
  else if (g_strcmp0 (method_name, "CreateWindow") == 0)
    {
      int width, height;
      gboolean alpha, maximized;

      g_variant_get (parameters, "(iibb)", &width, &height, &alpha, &maximized);

      create_window (width, height, alpha, maximized);
      g_dbus_method_invocation_return_value (invocation, NULL);
    }
  else if (g_strcmp0 (method_name, "WaitWindows") == 0)
    {
      wait_windows_invocations = g_list_prepend (wait_windows_invocations, invocation);
      check_finish_wait_windows ();
    }
  else if (g_strcmp0 (method_name, "DestroyWindows") == 0)
    {
      destroy_windows ();
      g_dbus_method_invocation_return_value (invocation, NULL);
    }
}