예제 #1
0
static void
on_response (SandboxFileChooserDialog *sfcd,
             gint response_id,
             gint state,
             gpointer user_data)
{
  ExampleAppWindow *win = (ExampleAppWindow *) user_data;

  g_printf ("Response: %d\nState: %d\n", response_id, state);

  if (state == SFCD_DATA_RETRIEVAL && response_id == GTK_RESPONSE_OK)
  {
    GError *error = NULL;
    gchar *path = sfcd_get_filename (dialog, &error);
    if (error)
    {
      g_printf ("Get Filename Error: %s\n", error->message);
      g_error_free (error); //TODO
    }
    else
    {
      GtkWidget *extra = sfcd_get_extra_widget (dialog, &error);
      if (error)
      {
        g_printf ("Get Widget Error: %s\n", error->message);
        g_error_free (error); //TODO

        GFile *file = g_file_new_for_path (path);
        example_app_window_open (win, file);
        g_free (path);
      }
      else
      {
        const gchar *font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (extra));
        PangoFontDescription *font_desc = pango_font_description_from_string (font);

        GFile *file = g_file_new_for_path (path);
        example_app_window_open_with_font (win, file, font_desc);

        g_free (path);
        pango_font_description_free (font_desc); 
      }
    }
  }
}
예제 #2
0
static void example_app_open(GApplication *app, GFile **files, gint n_files,
		const gchar *hint)
{
	GList *windows;
	Code0Window *win;
	int i;

	windows = gtk_application_get_windows(GTK_APPLICATION(app));
	if (windows)
		win = EXAMPLE_APP_WINDOW(windows->data);
	else
		win = example_app_window_new(EXAMPLE_APP(app));

	for (i = 0; i < n_files; i++)
		example_app_window_open(win, files[i]);

	gtk_window_present(GTK_WINDOW(win));
}