Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel.borgmann committed Feb 17, 2010
1 parent 1d6c288 commit 817d5bc
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 25 deletions.
15 changes: 14 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,21 @@ AM_PROG_VALAC([$VALA_REQUIRED])
VAPIDIR=`pkg-config --variable=vapidir vala-1.0`
AC_SUBST(VAPIDIR)

GNOME_COMPILE_WARNINGS(yes)

AC_CONFIG_FILES([Makefile])

AC_OUTPUT

dnl ==========================================================================
echo "
glasscat $VERSION
=============================

prefix: ${prefix}
C compiler: ${CC}
Vala compiler: ${VALAC}
cflags: ${CFLAGS}
cppflags: ${CPPFLAGS}
dbus enabled: ${have_dbus}
gconf-schema dir: $GCONF_SCHEMA_FILE_DIR
"
4 changes: 2 additions & 2 deletions src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Application : GLib.Object
return config_dir;
}

[NoArrayLength ()]
[CCode (array_length = false)]
public void run (string[] args) {
Gtk.init (ref args);

Expand Down Expand Up @@ -121,7 +121,7 @@ public class Application : GLib.Object
win_count = win_count + 1;

BaseWindow w;
if (g_content_type_guess (uri, null, null) == "application/x-glasscat-project") {
if (g_content_type_guess (uri, new uchar[0], null) == "application/x-glasscat-project") {
w = new ProjectWindow (uri);
} else {
w = new DocumentWindow (uri);
Expand Down
2 changes: 1 addition & 1 deletion src/basewindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class BaseWindow : Gtk.Window
setup_ui_manager ();
}

public static Clipboard get_clipboard () {
public static new Clipboard get_clipboard () {
return clipboard;
}

Expand Down
16 changes: 13 additions & 3 deletions src/document.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Document : SourceBuffer

this.file_name = uri_to_filename (uri);
this.metadata = new MetadataManager (Uri.escape_string (this.file_name, "", false));
this.mime_type = g_content_type_guess (uri, null, out result_uncertain);
this.mime_type = g_content_type_guess (uri, new uchar[0], out result_uncertain);

if (result_uncertain)
this.mime_type = null;
Expand All @@ -43,12 +43,22 @@ public class Document : SourceBuffer
// TODO: error dialogs, use gio
string contents;

if ( ! FileUtils.get_contents (file_name, out contents, null) )
try {
if ( ! FileUtils.get_contents (file_name, out contents, null) )
return false;
} catch (FileError e) {
stdout.printf ("Error while loading document: %s\n", e.message);
return false;
}

if ( ! contents.validate () ) {
/* this is lame .. */
contents = convert (contents, -1, "UTF-8", "ISO-8859-2", null, null);
try {
contents = convert (contents, -1, "UTF-8", "ISO-8859-2", null, null);
} catch (ConvertError e) {
stdout.printf ("Error while converting document: %s\n", e.message);
return false;
}
if ( ! contents.validate () ) {
return false;
}
Expand Down
8 changes: 5 additions & 3 deletions src/documentview.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public class DocumentView : SourceView

construct {
modify_font (FontDescription.from_string (SystemSettings.get_font ()));
GConf.Client.get_default().notify_add ("/desktop/gnome/interface/monospace_font_name", on_font_changed);
try {
GConf.Client.get_default().notify_add ("/desktop/gnome/interface/monospace_font_name", on_font_changed);
} catch (Error e) {
stdout.printf ("Failed to add GConf notification: %s", e.message);
}

this.tab_width = 8;
this.insert_spaces_instead_of_tabs = false;
Expand Down Expand Up @@ -127,8 +131,6 @@ public class DocumentView : SourceView
wrapped = true;
}
};

return false;
}

public new void select_all () {
Expand Down
12 changes: 8 additions & 4 deletions src/documentwindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public class DocumentWindow : BaseWindow
set_title (doc.get_title_string ());

// FIXME: should use document mimetype icon (wait for Gtk 2.14 and nicer API)
var icon = IconTheme.get_default ().load_icon ("glasscat", 16, (IconLookupFlags)0);
set_icon (icon);
try {
var icon = IconTheme.get_default ().load_icon ("glasscat", 16, (IconLookupFlags)0);
set_icon (icon);
} catch (Error e) {
stdout.printf ("Error while loading icon: %s\n", e.message);
}
}

public override bool is_document (string uri) {
Expand Down Expand Up @@ -65,7 +69,7 @@ public class DocumentWindow : BaseWindow
m.write ();
}

private void populate_window () {
private new void populate_window () {
base.populate_window ();

document_view = new DocumentView ();
Expand All @@ -74,7 +78,7 @@ public class DocumentWindow : BaseWindow
document_box.add (scrolled_window);
}

private void connect_events () {
private new void connect_events () {
delete_event += () => { save_spatial_state (); return false; };
base.connect_events ();
}
Expand Down
19 changes: 12 additions & 7 deletions src/metadata.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ public class MetadataManager : Object
file_name = Application.get_config_dir() + "/metadata/" + hash;

if ( FileUtils.test (file_name, FileTest.EXISTS) ) {
FileUtils.get_contents (file_name, out contents, null); // FIXME: use async gio?
var lines = contents.split ("\n");
try {
FileUtils.get_contents (file_name, out contents, null); // FIXME: use async gio?

var lines = contents.split ("\n");

foreach ( string line in lines ) {
var keyval = line.split (":");
if ( keyval[0] == null || keyval[1] == null )
continue;
keys.insert (keyval[0], keyval[1]);
foreach ( string line in lines ) {
var keyval = line.split (":");
if ( keyval[0] == null || keyval[1] == null )
continue;
keys.insert (keyval[0], keyval[1]);
}
} catch (FileError e) {
stdout.printf ("Error while loading metadata: %s\n", e.message);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/project.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Project : GLib.Object

try {
file.create (FileCreateFlags.NONE, null);
} catch (Error e) {
stdout.printf ("Error: %s\n", e.message);
} catch (IOError e) {
if (e is IOError.EXISTS)
stdout.printf ("File Exists\n");
Expand All @@ -27,4 +29,4 @@ public class Project : GLib.Object
}
}

}
}
8 changes: 5 additions & 3 deletions src/projectwindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ public class ProjectWindow : BaseWindow
try {
var icon = IconTheme.get_default ().load_icon ("glasscat", 16, (IconLookupFlags)0);
set_icon (icon);
} catch (GLib.FileError error) {
stdout.printf ("Failed to load application icon: %s\n", error.message);
} catch (Error e) {
stdout.printf ("Error: %s\n", e.message);
} catch (GLib.FileError e) {
stdout.printf ("Failed to load application icon: %s\n", e.message);
}
}

private void populate_window () {
private new void populate_window () {
base.populate_window ();

/* A hidden notebook with 10 DocumentView buffers. Set DocumentView to the first one. */
Expand Down

0 comments on commit 817d5bc

Please sign in to comment.