2005-07-13 05:44:22 +00:00
|
|
|
/* testtreefocus.c
|
|
|
|
* Copyright (C) 2001 Red Hat, Inc
|
|
|
|
* Author: Jonathan Blandford
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-07-13 05:44:22 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2001-03-08 21:36:34 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
typedef struct _TreeStruct TreeStruct;
|
|
|
|
struct _TreeStruct
|
|
|
|
{
|
|
|
|
const gchar *label;
|
2001-03-15 23:21:39 +00:00
|
|
|
gboolean alex;
|
2001-03-08 21:36:34 +00:00
|
|
|
gboolean havoc;
|
2001-03-15 23:21:39 +00:00
|
|
|
gboolean tim;
|
2001-03-08 21:36:34 +00:00
|
|
|
gboolean owen;
|
2001-04-12 16:11:54 +00:00
|
|
|
gboolean dave;
|
2001-03-15 23:21:39 +00:00
|
|
|
gboolean world_holiday; /* shared by the european hackers */
|
2001-03-08 21:36:34 +00:00
|
|
|
TreeStruct *children;
|
|
|
|
};
|
|
|
|
|
2001-04-12 16:11:54 +00:00
|
|
|
|
2001-03-08 21:36:34 +00:00
|
|
|
static TreeStruct january[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{"New Years Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
|
|
|
{"Presidential Inauguration", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
|
|
|
{"Martin Luther King Jr. day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct february[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Presidents' Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
|
|
|
{ "Groundhog Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Valentine's Day", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct march[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "National Tree Planting Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "St Patrick's Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct april[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "April Fools' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
|
|
|
{ "Army Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Earth Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
|
|
|
{ "Administrative Professionals' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct may[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Nurses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "National Day of Prayer", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Mothers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
|
|
|
{ "Armed Forces Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Memorial Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct june[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
|
|
|
{ "Juneteenth (Liberation of Slaves)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct july[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Parents' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
|
|
|
{ "Independence Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct august[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Air Force Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Coast Guard Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Friendship Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct september[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Grandparents' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
|
|
|
{ "Citizenship Day or Constitution Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Labor Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct october[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "National Children's Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Bosses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Sweetest Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Mother-in-Law's Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Navy Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Columbus Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
|
|
|
{ "Halloween", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct november[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Marine Corps Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Veterans' Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
|
|
|
{ "Thanksgiving", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static TreeStruct december[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{ "Pearl Harbor Remembrance Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
|
|
|
{ "Christmas", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
|
|
|
|
{ "Kwanzaa", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
|
2001-03-08 21:36:34 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static TreeStruct toplevel[] =
|
|
|
|
{
|
2001-04-12 16:11:54 +00:00
|
|
|
{"January", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, january},
|
|
|
|
{"February", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, february},
|
|
|
|
{"March", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, march},
|
|
|
|
{"April", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, april},
|
|
|
|
{"May", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, may},
|
|
|
|
{"June", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, june},
|
|
|
|
{"July", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, july},
|
|
|
|
{"August", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, august},
|
|
|
|
{"September", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, september},
|
|
|
|
{"October", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, october},
|
|
|
|
{"November", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, november},
|
|
|
|
{"December", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, december},
|
2001-03-08 21:36:34 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HOLIDAY_COLUMN = 0,
|
2001-03-15 23:21:39 +00:00
|
|
|
ALEX_COLUMN,
|
2001-03-08 21:36:34 +00:00
|
|
|
HAVOC_COLUMN,
|
2001-03-15 23:21:39 +00:00
|
|
|
TIM_COLUMN,
|
2001-03-08 21:36:34 +00:00
|
|
|
OWEN_COLUMN,
|
2001-04-12 16:11:54 +00:00
|
|
|
DAVE_COLUMN,
|
2001-03-08 21:36:34 +00:00
|
|
|
VISIBLE_COLUMN,
|
2001-03-15 23:21:39 +00:00
|
|
|
WORLD_COLUMN,
|
2001-03-08 21:36:34 +00:00
|
|
|
NUM_COLUMNS
|
|
|
|
};
|
|
|
|
|
|
|
|
static GtkTreeModel *
|
|
|
|
make_model (void)
|
|
|
|
{
|
|
|
|
GtkTreeStore *model;
|
|
|
|
TreeStruct *month = toplevel;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2001-06-30 02:38:17 +00:00
|
|
|
model = gtk_tree_store_new (NUM_COLUMNS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_BOOLEAN);
|
2001-03-08 21:36:34 +00:00
|
|
|
|
|
|
|
while (month->label)
|
|
|
|
{
|
|
|
|
TreeStruct *holiday = month->children;
|
|
|
|
|
|
|
|
gtk_tree_store_append (model, &iter, NULL);
|
|
|
|
gtk_tree_store_set (model, &iter,
|
|
|
|
HOLIDAY_COLUMN, month->label,
|
2001-03-15 23:21:39 +00:00
|
|
|
ALEX_COLUMN, FALSE,
|
2001-03-08 21:36:34 +00:00
|
|
|
HAVOC_COLUMN, FALSE,
|
2001-03-15 23:21:39 +00:00
|
|
|
TIM_COLUMN, FALSE,
|
2001-03-08 21:36:34 +00:00
|
|
|
OWEN_COLUMN, FALSE,
|
2001-04-12 16:11:54 +00:00
|
|
|
DAVE_COLUMN, FALSE,
|
2001-03-08 21:36:34 +00:00
|
|
|
VISIBLE_COLUMN, FALSE,
|
2001-03-15 23:21:39 +00:00
|
|
|
WORLD_COLUMN, FALSE,
|
2001-03-08 21:36:34 +00:00
|
|
|
-1);
|
|
|
|
while (holiday->label)
|
|
|
|
{
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
|
|
|
gtk_tree_store_append (model, &child_iter, &iter);
|
|
|
|
gtk_tree_store_set (model, &child_iter,
|
|
|
|
HOLIDAY_COLUMN, holiday->label,
|
2001-03-15 23:21:39 +00:00
|
|
|
ALEX_COLUMN, holiday->alex,
|
2001-03-08 21:36:34 +00:00
|
|
|
HAVOC_COLUMN, holiday->havoc,
|
2001-03-15 23:21:39 +00:00
|
|
|
TIM_COLUMN, holiday->tim,
|
2001-03-08 21:36:34 +00:00
|
|
|
OWEN_COLUMN, holiday->owen,
|
2001-04-12 16:11:54 +00:00
|
|
|
DAVE_COLUMN, holiday->dave,
|
2001-03-08 21:36:34 +00:00
|
|
|
VISIBLE_COLUMN, TRUE,
|
2001-03-15 23:21:39 +00:00
|
|
|
WORLD_COLUMN, holiday->world_holiday,
|
2001-03-08 21:36:34 +00:00
|
|
|
-1);
|
2001-03-13 02:00:37 +00:00
|
|
|
|
2001-03-08 21:36:34 +00:00
|
|
|
holiday ++;
|
|
|
|
}
|
|
|
|
month ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GTK_TREE_MODEL (model);
|
|
|
|
}
|
|
|
|
|
2001-03-15 23:21:39 +00:00
|
|
|
static void
|
|
|
|
alex_toggled (GtkCellRendererToggle *cell,
|
|
|
|
gchar *path_str,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = (GtkTreeModel *) data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
gboolean alex;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_model_get (model, &iter, ALEX_COLUMN, &alex, -1);
|
|
|
|
|
|
|
|
alex = !alex;
|
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, ALEX_COLUMN, alex, -1);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2001-03-08 21:36:34 +00:00
|
|
|
static void
|
|
|
|
havoc_toggled (GtkCellRendererToggle *cell,
|
|
|
|
gchar *path_str,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = (GtkTreeModel *) data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
gboolean havoc;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_model_get (model, &iter, HAVOC_COLUMN, &havoc, -1);
|
|
|
|
|
|
|
|
havoc = !havoc;
|
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, HAVOC_COLUMN, havoc, -1);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2001-03-13 02:00:37 +00:00
|
|
|
|
2001-03-08 21:36:34 +00:00
|
|
|
static void
|
|
|
|
owen_toggled (GtkCellRendererToggle *cell,
|
2001-03-15 23:21:39 +00:00
|
|
|
gchar *path_str,
|
|
|
|
gpointer data)
|
2001-03-08 21:36:34 +00:00
|
|
|
{
|
|
|
|
GtkTreeModel *model = (GtkTreeModel *) data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
gboolean owen;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_model_get (model, &iter, OWEN_COLUMN, &owen, -1);
|
|
|
|
|
|
|
|
owen = !owen;
|
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, OWEN_COLUMN, owen, -1);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2001-03-15 23:21:39 +00:00
|
|
|
static void
|
|
|
|
tim_toggled (GtkCellRendererToggle *cell,
|
|
|
|
gchar *path_str,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = (GtkTreeModel *) data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
gboolean tim;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_model_get (model, &iter, TIM_COLUMN, &tim, -1);
|
|
|
|
|
|
|
|
tim = !tim;
|
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, TIM_COLUMN, tim, -1);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2001-04-12 16:11:54 +00:00
|
|
|
static void
|
|
|
|
dave_toggled (GtkCellRendererToggle *cell,
|
|
|
|
gchar *path_str,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = (GtkTreeModel *) data;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
|
|
|
gboolean dave;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_model_get (model, &iter, DAVE_COLUMN, &dave, -1);
|
|
|
|
|
|
|
|
dave = !dave;
|
|
|
|
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, DAVE_COLUMN, dave, -1);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2006-01-13 13:28:22 +00:00
|
|
|
static void
|
|
|
|
set_indicator_size (GtkTreeViewColumn *column,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint size;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (model, iter);
|
2010-06-28 18:15:10 +00:00
|
|
|
size = gtk_tree_path_get_indices (path)[0] * 2 + 10;
|
2006-01-13 13:28:22 +00:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
g_object_set (cell, "indicator_size", size, NULL);
|
|
|
|
}
|
|
|
|
|
2001-03-08 21:36:34 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkWidget *tree_view;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkCellRenderer *renderer;
|
2001-03-15 23:21:39 +00:00
|
|
|
gint col_offset;
|
|
|
|
GtkTreeViewColumn *column;
|
2001-03-08 21:36:34 +00:00
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2001-04-12 16:11:54 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Card planning sheet");
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
|
2010-10-31 17:07:20 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
2016-10-02 15:37:22 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Jonathan's Holiday Card Planning Sheet"), FALSE, FALSE);
|
2001-03-08 21:36:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2016-10-02 15:37:22 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE);
|
2001-03-08 21:36:34 +00:00
|
|
|
|
|
|
|
model = make_model ();
|
2001-03-13 02:00:37 +00:00
|
|
|
tree_view = gtk_tree_view_new_with_model (model);
|
2001-06-07 22:33:14 +00:00
|
|
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
2001-08-27 19:42:08 +00:00
|
|
|
GTK_SELECTION_MULTIPLE);
|
2001-03-08 21:36:34 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2001-06-07 22:33:14 +00:00
|
|
|
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Holiday",
|
|
|
|
renderer,
|
|
|
|
"text", HOLIDAY_COLUMN, NULL);
|
2001-06-01 22:57:30 +00:00
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
|
|
|
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
2001-03-15 23:21:39 +00:00
|
|
|
|
|
|
|
/* Alex Column */
|
|
|
|
renderer = gtk_cell_renderer_toggle_new ();
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (renderer, "toggled", G_CALLBACK (alex_toggled), model);
|
2001-03-15 23:21:39 +00:00
|
|
|
|
2003-02-28 01:45:51 +00:00
|
|
|
g_object_set (renderer, "xalign", 0.0, NULL);
|
2001-03-15 23:21:39 +00:00
|
|
|
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Alex",
|
|
|
|
renderer,
|
|
|
|
"active", ALEX_COLUMN,
|
|
|
|
"visible", VISIBLE_COLUMN,
|
2001-09-25 16:44:39 +00:00
|
|
|
"activatable", WORLD_COLUMN,
|
2001-03-15 23:21:39 +00:00
|
|
|
NULL);
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
|
|
|
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
2001-09-08 00:56:30 +00:00
|
|
|
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
2001-06-01 22:57:30 +00:00
|
|
|
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
2001-03-15 23:21:39 +00:00
|
|
|
|
|
|
|
/* Havoc Column */
|
2001-03-08 21:36:34 +00:00
|
|
|
renderer = gtk_cell_renderer_toggle_new ();
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (renderer, "toggled", G_CALLBACK (havoc_toggled), model);
|
2001-03-08 21:36:34 +00:00
|
|
|
|
2003-02-28 01:45:51 +00:00
|
|
|
g_object_set (renderer, "xalign", 0.0, NULL);
|
2001-03-15 23:21:39 +00:00
|
|
|
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Havoc",
|
|
|
|
renderer,
|
|
|
|
"active", HAVOC_COLUMN,
|
|
|
|
"visible", VISIBLE_COLUMN,
|
|
|
|
NULL);
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
|
|
|
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
2001-09-08 00:56:30 +00:00
|
|
|
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
2001-06-01 22:57:30 +00:00
|
|
|
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
2001-03-15 23:21:39 +00:00
|
|
|
|
|
|
|
/* Tim Column */
|
|
|
|
renderer = gtk_cell_renderer_toggle_new ();
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (renderer, "toggled", G_CALLBACK (tim_toggled), model);
|
2001-03-15 23:21:39 +00:00
|
|
|
|
2003-02-28 01:45:51 +00:00
|
|
|
g_object_set (renderer, "xalign", 0.0, NULL);
|
2001-03-15 23:21:39 +00:00
|
|
|
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Tim",
|
2001-03-08 21:36:34 +00:00
|
|
|
renderer,
|
2001-03-15 23:21:39 +00:00
|
|
|
"active", TIM_COLUMN,
|
2001-03-08 21:36:34 +00:00
|
|
|
"visible", VISIBLE_COLUMN,
|
2001-09-25 16:44:39 +00:00
|
|
|
"activatable", WORLD_COLUMN,
|
2001-03-08 21:36:34 +00:00
|
|
|
NULL);
|
2001-03-15 23:21:39 +00:00
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
|
|
|
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
2001-06-01 22:57:30 +00:00
|
|
|
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
2001-09-08 00:56:30 +00:00
|
|
|
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
2001-03-15 23:21:39 +00:00
|
|
|
|
|
|
|
/* Owen Column */
|
2001-03-08 21:36:34 +00:00
|
|
|
renderer = gtk_cell_renderer_toggle_new ();
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (renderer, "toggled", G_CALLBACK (owen_toggled), model);
|
2003-02-28 01:45:51 +00:00
|
|
|
g_object_set (renderer, "xalign", 0.0, NULL);
|
2001-03-15 23:21:39 +00:00
|
|
|
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
2001-03-08 21:36:34 +00:00
|
|
|
-1, "Owen",
|
|
|
|
renderer,
|
|
|
|
"active", OWEN_COLUMN,
|
|
|
|
"visible", VISIBLE_COLUMN,
|
|
|
|
NULL);
|
2001-03-15 23:21:39 +00:00
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
|
|
|
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
2001-06-01 22:57:30 +00:00
|
|
|
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
2001-09-08 00:56:30 +00:00
|
|
|
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
2001-03-13 02:00:37 +00:00
|
|
|
|
2001-04-12 16:11:54 +00:00
|
|
|
/* Owen Column */
|
|
|
|
renderer = gtk_cell_renderer_toggle_new ();
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (renderer, "toggled", G_CALLBACK (dave_toggled), model);
|
2003-02-28 01:45:51 +00:00
|
|
|
g_object_set (renderer, "xalign", 0.0, NULL);
|
2001-04-12 16:11:54 +00:00
|
|
|
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Dave",
|
|
|
|
renderer,
|
|
|
|
"active", DAVE_COLUMN,
|
|
|
|
"visible", VISIBLE_COLUMN,
|
|
|
|
NULL);
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
2006-01-13 13:28:22 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer, set_indicator_size, NULL, NULL);
|
2001-04-12 16:11:54 +00:00
|
|
|
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
2001-09-08 00:56:30 +00:00
|
|
|
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
2001-06-01 22:57:30 +00:00
|
|
|
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
2001-04-12 16:11:54 +00:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
|
|
|
|
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (tree_view, "realize",
|
|
|
|
G_CALLBACK (gtk_tree_view_expand_all),
|
|
|
|
NULL);
|
2001-04-12 16:11:54 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window),
|
|
|
|
650, 400);
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Model");
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
|
2010-10-31 17:07:20 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
2016-10-02 15:37:22 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("The model revealed"), FALSE, FALSE);
|
2001-04-12 16:11:54 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2016-10-02 15:37:22 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE);
|
2001-04-12 16:11:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
tree_view = gtk_tree_view_new_with_model (model);
|
2002-10-13 23:22:33 +00:00
|
|
|
g_object_unref (model);
|
2001-04-12 16:11:54 +00:00
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Holiday Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 0, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Alex Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 1, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Havoc Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 2, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Tim Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 3, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Owen Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 4, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Dave Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 5, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "Visible Column",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 6, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
|
|
|
|
-1, "World Holiday",
|
2001-08-19 06:58:11 +00:00
|
|
|
gtk_cell_renderer_text_new (),
|
2001-04-12 16:11:54 +00:00
|
|
|
"text", 7, NULL);
|
|
|
|
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (tree_view, "realize",
|
|
|
|
G_CALLBACK (gtk_tree_view_expand_all),
|
|
|
|
NULL);
|
2001-04-12 16:11:54 +00:00
|
|
|
|
2001-03-15 23:21:39 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
|
|
|
|
|
2001-04-12 16:11:54 +00:00
|
|
|
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window),
|
|
|
|
650, 400);
|
|
|
|
|
2001-03-16 22:59:24 +00:00
|
|
|
gtk_widget_show_all (window);
|
2001-03-08 21:36:34 +00:00
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|