From d111cd15f1d8ac57831e4a1c0564efbd7b1a8996 Mon Sep 17 00:00:00 2001 From: Søren Sandmann Date: Fri, 11 Jul 2008 22:24:19 -0400 Subject: TODO --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index 879a0ca..321383f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ - Icon + - Set the image as icon when one is loaded - Recent files -- cgit v1.2.3 From 7b6f2ae288b1f61242c14898070b2d1254000307 Mon Sep 17 00:00:00 2001 From: Søren Sandmann Date: Sat, 25 Oct 2008 01:10:09 -0400 Subject: s/DEP/DEPENDENCIES/ --- Makefile.am | 4 ++-- configure.ac | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4e710f1..0d62197 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,8 +20,8 @@ bin_PROGRAMS = siv -siv_CFLAGS = $(DEP_CFLAGS) -DDATADIR=\"$(pkgdatadir)\" -siv_LDADD = $(DEP_LIBS) +siv_CFLAGS = $(DEPENDENCIES_CFLAGS) -DDATADIR=\"$(pkgdatadir)\" +siv_LDADD = $(DEPENDENCIES_LIBS) siv_SOURCES = \ siv.c \ diff --git a/configure.ac b/configure.ac index 0106d06..79fbad7 100644 --- a/configure.ac +++ b/configure.ac @@ -33,8 +33,8 @@ AC_PROG_INSTALL CFLAGS="-Wall $CFLAGS" # Checks for pkg-config packages -PKG_CHECK_MODULES(DEP, gtk+-2.0 libglade-2.0) -AC_SUBST(DEP_CFLAGS) -AC_SUBST(DEP_LIBS) +PKG_CHECK_MODULES(DEPENDENCIES, gtk+-2.0 libglade-2.0 libnul) +AC_SUBST(DEPENDENCIES_CFLAGS) +AC_SUBST(DEPENDENCIES_LIBS) AC_OUTPUT([Makefile]) -- cgit v1.2.3 From cb7c1d886e39bad3e39931d9690e125ef5cec101 Mon Sep 17 00:00:00 2001 From: Søren Sandmann Date: Sat, 25 Oct 2008 01:42:30 -0400 Subject: Split option processing out into its own function --- siv.c | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/siv.c b/siv.c index e992732..33c1136 100644 --- a/siv.c +++ b/siv.c @@ -321,15 +321,11 @@ app_set_meta_data (App *app, g_hash_table_destroy (table); } - -static void -app_new (int argc, char **argv) +static char ** +process_options (int argc, char **argv) { - GList *filenames = NULL; - GList *list; - App *app; int i; - GPtrArray *err_files = g_ptr_array_new (); + GPtrArray *result = g_ptr_array_new (); for (i = 1; i < argc; ++i) { @@ -342,24 +338,33 @@ app_new (int argc, char **argv) g_print ("%s %s\n", APPLICATION_NAME, PACKAGE_VERSION); exit (1); - return; + return NULL; } if (g_path_is_absolute (option)) - { name = g_strdup (option); - } else - { name = g_build_filename (g_get_current_dir(), option, NULL); - } - filenames = g_list_prepend (filenames, name); + g_ptr_array_add (result, name); } + g_ptr_array_add (result, NULL); + + return (char **)g_ptr_array_free (result, FALSE); +} + +static void +app_new (int argc, char **argv) +{ + GPtrArray *err_files = g_ptr_array_new (); + char **filenames; + App *app; + int i; + + filenames = process_options (argc, argv); + app = g_new0 (App, 1); - - filenames = g_list_reverse (filenames); /* When a window is created, it increases the app->n_windows counter; * when it is destroyed it decreases it. The problem is if the first @@ -370,17 +375,14 @@ app_new (int argc, char **argv) * prevent that from happening. */ app->n_windows = 1; - - if (filenames) - { - int i; - i = 0; - for (list = filenames; list != NULL; list = list->next) + if (filenames[0]) + { + for (i = 0; filenames[i] != NULL; ++i) { SivWindow *window; GError *err = NULL; - char *filename = list->data; + char *filename = filenames[i]; /* Don't open more than 32 windows */ if (++i > 32) @@ -388,7 +390,7 @@ app_new (int argc, char **argv) window = window_new (app); - if (!window_load_file (window, list->data, &err)) + if (!window_load_file (window, filename, &err)) { g_ptr_array_add (err_files, g_strdup (filename)); g_error_free (err); @@ -400,17 +402,14 @@ app_new (int argc, char **argv) window_show (window, GDK_CURRENT_TIME); } } - - for (list = filenames; list != NULL; list = list->next) - g_free (list->data); - - g_list_free (filenames); } else { window_show (window_new (app), GDK_CURRENT_TIME); } + g_strfreev (filenames); + app_show_could_not_open (NULL, err_files->len, (char **)err_files->pdata); g_ptr_array_foreach (err_files, (GFunc)g_free, NULL); -- cgit v1.2.3