Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorota Czaplejewicz
gtk
Commits
080fc7ec
Commit
080fc7ec
authored
Oct 09, 2005
by
Matthias Clasen
Browse files
Demonstrate custom widgets in a GtkComboBox.
parent
6592f00a
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
080fc7ec
2005-10-09 Matthias Clasen <mclasen@redhat.com>
* tests/testcombo.c: Demonstrate how to use custom widgets in
a GtkComboBox.
2005-10-07 Federico Mena Quintero <federico@ximian.com>
Fixes bug #317999:
...
...
ChangeLog.pre-2-10
View file @
080fc7ec
2005-10-09 Matthias Clasen <mclasen@redhat.com>
* tests/testcombo.c: Demonstrate how to use custom widgets in
a GtkComboBox.
2005-10-07 Federico Mena Quintero <federico@ximian.com>
Fixes bug #317999:
...
...
tests/testcombo.c
View file @
080fc7ec
...
...
@@ -893,6 +893,19 @@ is_separator (GtkTreeModel *model,
}
static
void
displayed_row_changed
(
GtkComboBox
*
combo
,
GtkCellView
*
cell
)
{
gint
row
;
GtkTreePath
*
path
;
row
=
gtk_combo_box_get_active
(
combo
);
path
=
gtk_tree_path_new_from_indices
(
row
,
-
1
);
gtk_cell_view_set_displayed_row
(
cell
,
path
);
gtk_tree_path_free
(
path
);
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -904,6 +917,7 @@ main (int argc, char **argv)
GtkTreeModel
*
model
;
GtkTreePath
*
path
;
GtkTreeIter
iter
;
GdkColor
color
;
gtk_init
(
&
argc
,
&
argv
);
...
...
@@ -984,6 +998,66 @@ main (int argc, char **argv)
gtk_combo_box_set_active
(
GTK_COMBO_BOX
(
combobox
),
0
);
/* GtkComboBox custom entry */
tmp
=
gtk_frame_new
(
"GtkComboBox (custom)"
);
gtk_box_pack_start
(
GTK_BOX
(
mainbox
),
tmp
,
FALSE
,
FALSE
,
0
);
boom
=
gtk_vbox_new
(
FALSE
,
0
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
boom
),
5
);
gtk_container_add
(
GTK_CONTAINER
(
tmp
),
boom
);
model
=
create_list_blaat
();
combobox
=
gtk_combo_box_new_with_model
(
model
);
gtk_combo_box_set_add_tearoffs
(
GTK_COMBO_BOX
(
combobox
),
TRUE
);
g_object_unref
(
model
);
gtk_container_add
(
GTK_CONTAINER
(
boom
),
combobox
);
renderer
=
gtk_cell_renderer_pixbuf_new
();
gtk_cell_layout_pack_start
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
FALSE
);
gtk_cell_layout_set_attributes
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
"pixbuf"
,
0
,
NULL
);
gtk_cell_layout_set_cell_data_func
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
set_sensitive
,
NULL
,
NULL
);
renderer
=
gtk_cell_renderer_text_new
();
gtk_cell_layout_pack_start
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
TRUE
);
gtk_cell_layout_set_attributes
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
"text"
,
1
,
NULL
);
gtk_cell_layout_set_cell_data_func
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
set_sensitive
,
NULL
,
NULL
);
gtk_combo_box_set_row_separator_func
(
GTK_COMBO_BOX
(
combobox
),
is_separator
,
NULL
,
NULL
);
gtk_combo_box_set_active
(
GTK_COMBO_BOX
(
combobox
),
0
);
tmp
=
gtk_cell_view_new
();
gtk_widget_show
(
tmp
);
gtk_cell_view_set_model
(
GTK_CELL_VIEW
(
tmp
),
model
);
renderer
=
gtk_cell_renderer_text_new
();
gtk_cell_layout_pack_start
(
GTK_CELL_LAYOUT
(
tmp
),
renderer
,
TRUE
);
gtk_cell_layout_set_attributes
(
GTK_CELL_LAYOUT
(
tmp
),
renderer
,
"text"
,
1
,
NULL
);
color
.
red
=
0xffff
;
color
.
blue
=
0xffff
;
color
.
green
=
0
;
gtk_cell_view_set_background_color
(
GTK_CELL_VIEW
(
tmp
),
&
color
);
displayed_row_changed
(
GTK_COMBO_BOX
(
combobox
),
GTK_CELL_VIEW
(
tmp
));
g_signal_connect
(
combobox
,
"changed"
,
G_CALLBACK
(
displayed_row_changed
),
tmp
);
gtk_container_add
(
GTK_CONTAINER
(
combobox
),
tmp
);
/* GtkComboBox tree */
tmp
=
gtk_frame_new
(
"GtkComboBox (tree)"
);
gtk_box_pack_start
(
GTK_BOX
(
mainbox
),
tmp
,
FALSE
,
FALSE
,
0
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment