first, almost ready UI
[irreco.git] / irreco / src / core / irreco_theme_creator_backgrounds.c
blobff6c512e9d73612962b4bae3437ded91bdee1bc9
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * irreco_theme_creator_backgrounds.c
4 * Copyright (C) 2008 <>
5 *
6 * irreco_theme_creator_backgrounds.c is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * irreco_theme_creator_backgrounds.c is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "irreco_theme_creator_backgrounds.h"
21 #include "irreco_theme_creator_dlg.h"
23 /**
24 * @addtogroup IrrecoThemeCreatorBackgrounds
25 * @ingroup Irreco
27 * User interface for IrrecoThemeCreatorDlgBackgrounds.
29 * @{
32 /**
33 * @file
34 * Source file of @ref IrrecoThemeCreatorBackgrounds.
37 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
38 /* Datatypes */
39 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
41 #define IRRECO_BACKGROUNDS_PREVIEW_WIDHT (IRRECO_SCREEN_WIDTH / 6)
42 #define IRRECO_BACKGROUNDS_PREVIEW_HEIGHT (IRRECO_SCREEN_HEIGHT / 6)
44 enum
46 DATA_COL,
47 TEXT_COL,
48 PIXBUF_COL,
49 N_COLUMNS
54 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
55 /* Prototypes. */
56 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
64 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
65 /* Construction & Destruction */
66 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
68 /**
69 * @name Construction & Destruction
70 * @{
75 G_DEFINE_TYPE (IrrecoThemeCreatorBackgrounds, irreco_theme_creator_backgrounds,
76 IRRECO_TYPE_INTERNAL_WIDGET)
79 static void
80 irreco_theme_creator_backgrounds_finalize (GObject *object)
82 /* TODO: Add deinitalization code here */
83 IRRECO_ENTER
84 G_OBJECT_CLASS(
85 irreco_theme_creator_backgrounds_parent_class)->finalize (object);
86 IRRECO_RETURN
90 static void
91 irreco_theme_creator_backgrounds_class_init
92 (IrrecoThemeCreatorBackgroundsClass *klass)
94 GObjectClass *object_class;
95 IRRECO_ENTER
97 object_class = G_OBJECT_CLASS (klass);
98 object_class->finalize = irreco_theme_creator_backgrounds_finalize;
99 IRRECO_RETURN
102 static void
103 irreco_theme_creator_backgrounds_init (IrrecoThemeCreatorBackgrounds *self)
105 /* TODO: Add initialization code here */
107 /*Backgrounds widgets*/
111 IRRECO_ENTER
113 gtk_box_set_spacing(GTK_BOX(self), 1);
115 /*BACKGROUNDS*/
117 self->scroll_backgrounds = gtk_scrolled_window_new(NULL, NULL);
118 self->store_backgrounds = gtk_list_store_new(2, GDK_TYPE_PIXBUF,
119 G_TYPE_STRING);
120 self->view_backgrounds = gtk_tree_view_new();
122 gtk_box_pack_start_defaults(GTK_BOX(self), self->scroll_backgrounds);
124 /*BACKGROUNDS COLUMNS*/
125 gtk_tree_view_set_model(GTK_TREE_VIEW(self->view_backgrounds),
126 GTK_TREE_MODEL(self->store_backgrounds));
127 g_object_unref(self->store_backgrounds);
129 /* Create pixbuf column. */
130 self->renderer_backgrounds = gtk_cell_renderer_pixbuf_new();
131 self->column_backgrounds = gtk_tree_view_column_new_with_attributes(
132 "Background ",
133 self->renderer_backgrounds,
134 "pixbuf", PIXBUF_COL, NULL);
135 gtk_tree_view_append_column(GTK_TREE_VIEW(self->view_backgrounds),
136 self->column_backgrounds);
138 /* Create text column. */
139 self->renderer_backgrounds = gtk_cell_renderer_text_new();
140 self->column_backgrounds = gtk_tree_view_column_new_with_attributes(
141 "Name ",
142 self->renderer_backgrounds,
143 "text", TEXT_COL, NULL);
144 gtk_tree_view_append_column(GTK_TREE_VIEW(self->view_backgrounds),
145 self->column_backgrounds);
146 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(self->view_backgrounds),
147 TRUE);
150 /* Scroll_backgrounds*/
152 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self->scroll_backgrounds),
153 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
154 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(
155 self->scroll_backgrounds),
156 self->view_backgrounds);
157 IRRECO_RETURN
160 GtkWidget* irreco_theme_creator_backgrounds_new(GtkWindow *parent,
161 IrrecoData *irreco_data,
162 IrrecoTheme * irreco_theme)
164 IrrecoThemeCreatorBackgrounds *self;
165 IRRECO_ENTER
167 self = g_object_new(IRRECO_TYPE_THEME_CREATOR_BACKGROUNDS,
168 "irreco-data", irreco_data,
169 NULL);
171 irreco_theme_creator_backgrounds_set_parent_window(self, parent);
172 IRRECO_RETURN_PTR(GTK_WIDGET(self));
175 /** @} */
179 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
180 /* Private Functions */
181 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
184 * @name Private Functions
185 * @{
189 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
190 /* Public Functions */
191 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
194 * @name Public Functions
195 * @{
199 * Set parent window for popup dialogs.
201 void
202 irreco_theme_creator_backgrounds_set_parent_window(
203 IrrecoThemeCreatorBackgrounds *self,
204 GtkWindow *parent)
206 IRRECO_ENTER
207 self->parent_window = parent;
208 IRRECO_RETURN