Пример #1
0
void
show_help_dialog (GtkWindow  *parent,
		  const char *section)
{
	char   *uri;
	GError *error = NULL;

	uri = g_strconcat ("help:engrampa", section ? "/" : NULL, section, NULL);
	if (! show_uri (gtk_window_get_screen (parent), uri, GDK_CURRENT_TIME, &error)) {
  		GtkWidget *dialog;

		dialog = _gtk_message_dialog_new (parent,
						  GTK_DIALOG_DESTROY_WITH_PARENT,
						  GTK_STOCK_DIALOG_ERROR,
						  _("Could not display help"),
						  error->message,
						  GTK_STOCK_OK, GTK_RESPONSE_OK,
						  NULL);
		gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

		g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (gtk_widget_destroy),
				  NULL);

		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

		gtk_widget_show (dialog);

		g_clear_error (&error);
	}
	g_free (uri);
}
Пример #2
0
static void
recent_documents_activate_cb (GtkRecentChooser *chooser,
			      gpointer          data)
{
	GtkRecentInfo *recent_info;
	const char    *uri;
	const char    *mime_type;
	GdkScreen     *screen;
	GError        *error = NULL;

	screen = gtk_widget_get_screen (GTK_WIDGET (chooser));
	
	recent_info = gtk_recent_chooser_get_current_item (chooser);
	uri = gtk_recent_info_get_uri (recent_info);
	mime_type = gtk_recent_info_get_mime_type (recent_info);
	//FIXME gtk_recent_info_get_application_info() could be useful

	if (show_uri (uri, mime_type, screen, &error) != TRUE) {
		char *uri_utf8;

		uri_utf8 = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
		//FIXME this could fail... Maybe we want gtk_recent_info_get_display_name()

		if (error) {
			char *primary;
			primary = g_strdup_printf (_("Could not open recently used document \"%s\""),
						   uri_utf8);
			panel_error_dialog (NULL, screen,
					    "cannot_open_recent_doc", TRUE,
					    primary, error->message);
			g_free (primary);
			g_error_free (error);
		} else {
			char *primary;
			char *secondary;
			primary = g_strdup_printf (_("Could not open recently used document \"%s\""),
						   uri_utf8);
			secondary = g_strdup_printf (_("An unknown error occurred while trying to open \"%s\"."),
						     uri_utf8);
			panel_error_dialog (NULL, screen,
					    "cannot_open_recent_doc", TRUE,
					    primary, secondary);
			g_free (primary);
			g_free (secondary);
		}

		g_free (uri_utf8);
	}

	/* we can unref it only after having used the data we fetched from it */
	gtk_recent_info_unref (recent_info);
}