From b3a099e3ee32ce6b93358a9d7b637ad20fdb08c2 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Thu, 17 Oct 2013 20:37:14 -0400 Subject: [PATCH] Code cleanup (tree view store init) --- src/memwin.c | 12 +++++------- src/pgmwin.c | 14 +++++++------- src/regwin.c | 12 +++++------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/memwin.c b/src/memwin.c index 24d3071..53bb982 100644 --- a/src/memwin.c +++ b/src/memwin.c @@ -51,22 +51,20 @@ static GtkListStore * memwin_init_store(void) { GtkTreeIter iter; - int rows; + int row; int col; GtkListStore *store; GType col_types[N_COLUMNS]; - for (col = 0; col < N_COLUMNS; col++) { + /* No need for static array, all our columns are of the same type. */ + for (col = 0; col < N_COLUMNS; col++) col_types[col] = G_TYPE_STRING; - } store = gtk_list_store_newv(N_COLUMNS, col_types); - /* Initialize with rows of dummy data... */ - for (rows = 0; rows < DATA_ROWS; rows++) { - /* Add new row. */ + /* Add rows. */ + for (row = 0; row < DATA_ROWS; row++) gtk_list_store_append(store, &iter); - } return store; } diff --git a/src/pgmwin.c b/src/pgmwin.c index b139754..04cff15 100644 --- a/src/pgmwin.c +++ b/src/pgmwin.c @@ -64,7 +64,7 @@ static GtkListStore * pgmwin_init_store(void) { GtkTreeIter iter; - int rows; + int row; int col; GtkListStore *store; GType col_types[N_COLUMNS]; @@ -75,15 +75,15 @@ pgmwin_init_store(void) store = gtk_list_store_newv(N_COLUMNS, col_types); - /* Initialize with rows of dummy data... */ - for (rows = 0; rows < DATA_ROWS; rows++) { + /* Add rows. */ + for (row = 0; row < DATA_ROWS; row++) { gtk_list_store_append(store, &iter); - if (rows == 0) { - /* Color first row in red (current instruction). */ + + /* Color first row in red (current instruction). */ + if (row == 0) gtk_list_store_set(store, &iter, COL_COLOR, "red", -1); - } else { + else gtk_list_store_set(store, &iter, COL_COLOR, "black", -1); - } } return store; diff --git a/src/regwin.c b/src/regwin.c index 4cba816..e3b79d7 100644 --- a/src/regwin.c +++ b/src/regwin.c @@ -282,22 +282,20 @@ static GtkListStore * regwin_init_store(void) { GtkTreeIter iter; - int rows; + int row; int col; GtkListStore *store; GType col_types[N_COLUMNS]; - for (col = 0; col < N_COLUMNS; col++) { + /* No need for static array, all our columns are of the same type. */ + for (col = 0; col < N_COLUMNS; col++) col_types[col] = G_TYPE_STRING; - } store = gtk_list_store_newv(N_COLUMNS, col_types); - /* Initialize with rows of dummy data... */ - for (rows = 0; rows < DATA_ROWS; rows++) { - /* Add new row. */ + /* Add rows. */ + for (row = 0; row < DATA_ROWS; row++) gtk_list_store_append(store, &iter); - } return store; } -- 2.20.1