summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-07-31 18:57:56 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-07-31 18:57:56 +0000
commit5b08312353b05feebfaa7f8557bec3fdb3a9f6cd (patch)
treec6bf90470036cbabfd95c86e749b1519289704cf /examples
parent990ed879243b190ee1926188fef04ce1fb04a619 (diff)
downloadpango-5b08312353b05feebfaa7f8557bec3fdb3a9f6cd.tar.gz
Remove hardcoded path to my home directory! Allow specifying the file on
Sat Jul 29 21:26:30 2000 Owen Taylor <otaylor@redhat.com> * examples/viewer-qt.[ch] (ViewerWindow): Remove hardcoded path to my home directory! Allow specifying the file on the command line. * pango/modules.c (process_module_file): Fix bug in parsing of range strings.
Diffstat (limited to 'examples')
-rw-r--r--examples/viewer-qt.cc22
-rw-r--r--examples/viewer-qt.h2
2 files changed, 18 insertions, 6 deletions
diff --git a/examples/viewer-qt.cc b/examples/viewer-qt.cc
index 0f5aeae0..8afc09e5 100644
--- a/examples/viewer-qt.cc
+++ b/examples/viewer-qt.cc
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <qapplication.h>
#include <qcdestyle.h>
@@ -165,7 +166,12 @@ ViewerView::readFile (const QString &name)
{
QFile file (name);
- file.open (IO_ReadOnly);
+ if (!file.open (IO_ReadOnly))
+ {
+ fprintf (stderr, "Cannot open file '%s'\n");
+ return;
+ }
+
QTextStream ts (&file);;
ts.setCodec (QTextCodec::codecForName ("utf8"));
@@ -349,7 +355,7 @@ cmp_strings (const void *a, const void *b)
return strcmp (*(const char **)a, *(const char **)b);
}
-ViewerWindow::ViewerWindow ()
+ViewerWindow::ViewerWindow (const QString &filename)
{
// Create menu
@@ -401,7 +407,7 @@ ViewerWindow::ViewerWindow ()
fontChanged ();
- view_->readFile ("/home/otaylor/devel/pango/examples/HELLO.utf8");
+ view_->readFile (filename);
resize (500, 500);
}
@@ -500,13 +506,19 @@ int
main (int argc, char **argv)
{
QApplication a (argc, argv);
+ const char *filename;
QApplication::setStyle (new QCDEStyle());
if (QFileInfo ("./pangorc").exists ())
putenv ("PANGO_RC_FILE=./pangorc");
-
- ViewerWindow *vw = new ViewerWindow ();
+
+ if (argc == 2)
+ filename = argv[1];
+ else
+ filename = "HELLO.utf8";
+
+ ViewerWindow *vw = new ViewerWindow (filename);
vw->show();
diff --git a/examples/viewer-qt.h b/examples/viewer-qt.h
index c03a543d..c8d8001b 100644
--- a/examples/viewer-qt.h
+++ b/examples/viewer-qt.h
@@ -89,7 +89,7 @@ class ViewerWindow : public QMainWindow
public:
- ViewerWindow ();
+ ViewerWindow (const QString &filename);
~ViewerWindow ();
private: