forked from AuroraMiddleware/gtk
4a3c8a367a
2001-02-08 Havoc Pennington <hp@redhat.com> * gtk/gtktextview.c (gtk_text_view_destroy_layout): remove validation idle * demos/gtk-demo/main.c (create_tree): adjust to changes in text cell renderer * demos/pixbuf-demo.c (timeout): remove deprecated gtk_widget_draw * demos/testpixbuf-save.c (main): remove deprecated gtk_drawing_area_size * gtk/gtktreeview.c (gtk_tree_view_size_allocate): allocate buttons even if the model isn't setup. gtk_tree_view_check_dirty() at the start of the allocation. (gtk_tree_view_check_dirty): handle column->button == NULL, handle unsetup or NULL model. * gtk/gtkstyle.c (gtk_default_draw_flat_box): drawing for the even/odd/sorted cells in the tree view. * gtk/gtktreeselection.c (gtk_tree_selection_real_unselect_all): bugfixes * gtk/gtktreeview.c: assorted bugfixy stuff. Draw the row backgrounds with draw_flat_box using different detail for even/odd rows. * gtk/gtkrbtree.c, gtkrbtree.h: Keep track of the parity of each row, so we can draw the alternating colors thing * gtk/gtktexttag.c (gtk_text_tag_set_property): if we change a property from a synonym property, notify for the synonym. Also, nuke the background_gdk_set and foreground_gdk_set synonyms (gtk_text_tag_get_property): Always return the font, even if all its fields aren't set * gtk/gtkcellrenderertext.h (struct _GtkCellRendererText): don't store the attr list; it leaves us with no way to change attributes in _render according to the render flags, and no way to implement get_property. Instead store all the specific text attributes. Separate whether an attribute is enabled from its value. Sync all properties with GtkTextTag, make them all consistent, etc. * gtk/gtkcellrenderer.h: Add a flag GTK_CELL_RENDERER_SORTED so renderers can highlight the sort row/column * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_property): use accessor functions to get values; this has the side effect of showing up which accessor functions were missing. Added those. * gtk/gtktreeviewcolumn.h: Replace set_justification with set_alignment, to be consistent with GtkLabel, GtkMisc * gtk/gtktreeviewcolumn.c: Added code to display sort indicator arrow. * gtk/Makefile.am (gtk_public_h_sources): add gtktreesortable.h * gtk/gtktreesortable.h: updates in here
155 lines
5.8 KiB
C
155 lines
5.8 KiB
C
|
|
#include <config.h>
|
|
/* if building outside GTK, remove /x11 part */
|
|
#include <gdk/x11/gdkx.h>
|
|
#include <gtk/gtk.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
void
|
|
keypress_check (GtkWidget *widget, GdkEventKey *evt, gpointer data)
|
|
{
|
|
GdkPixbuf *pixbuf;
|
|
GtkDrawingArea *da = (GtkDrawingArea*)data;
|
|
GError *err = NULL;
|
|
|
|
pixbuf = (GdkPixbuf *) gtk_object_get_data (GTK_OBJECT (da), "pixbuf");
|
|
|
|
if (evt->keyval == 'q')
|
|
gtk_main_quit ();
|
|
if (evt->keyval == 's') {
|
|
if (pixbuf == NULL) {
|
|
fprintf (stderr, "PIXBUF NULL\n");
|
|
return;
|
|
}
|
|
|
|
if (!gdk_pixbuf_save (pixbuf, "foo.jpg", "jpeg",
|
|
&err,
|
|
"quality", "100",
|
|
NULL)) {
|
|
fprintf (stderr, "%s", err->message);
|
|
g_error_free (err);
|
|
}
|
|
|
|
} else if (evt->keyval == 'p') {
|
|
if (pixbuf == NULL) {
|
|
fprintf (stderr, "PIXBUF NULL\n");
|
|
return;
|
|
}
|
|
|
|
if (!gdk_pixbuf_save (pixbuf, "foo.png", "png", &err, NULL)) {
|
|
fprintf (stderr, "%s", err->message);
|
|
g_error_free (err);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int
|
|
close_app (GtkWidget *widget, gpointer data)
|
|
{
|
|
gtk_main_quit ();
|
|
return TRUE;
|
|
}
|
|
|
|
int
|
|
expose_cb (GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
|
{
|
|
GdkPixbuf *pixbuf;
|
|
|
|
pixbuf = (GdkPixbuf *) gtk_object_get_data (GTK_OBJECT (drawing_area),
|
|
"pixbuf");
|
|
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
|
|
gdk_draw_rgb_32_image (drawing_area->window,
|
|
drawing_area->style->black_gc,
|
|
evt->area.x, evt->area.y,
|
|
evt->area.width,
|
|
evt->area.height,
|
|
GDK_RGB_DITHER_MAX,
|
|
gdk_pixbuf_get_pixels (pixbuf) +
|
|
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
|
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
|
gdk_pixbuf_get_rowstride (pixbuf));
|
|
} else {
|
|
gdk_draw_rgb_image (drawing_area->window,
|
|
drawing_area->style->black_gc,
|
|
evt->area.x, evt->area.y,
|
|
evt->area.width,
|
|
evt->area.height,
|
|
GDK_RGB_DITHER_NORMAL,
|
|
gdk_pixbuf_get_pixels (pixbuf) +
|
|
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
|
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
|
gdk_pixbuf_get_rowstride (pixbuf));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int
|
|
configure_cb (GtkWidget *drawing_area, GdkEventConfigure *evt, gpointer data)
|
|
{
|
|
GdkPixbuf *pixbuf;
|
|
|
|
pixbuf = (GdkPixbuf *) gtk_object_get_data (GTK_OBJECT (drawing_area),
|
|
"pixbuf");
|
|
|
|
g_print ("X:%d Y:%d\n", evt->width, evt->height);
|
|
if (evt->width != gdk_pixbuf_get_width (pixbuf) || evt->height != gdk_pixbuf_get_height (pixbuf)) {
|
|
GdkWindow *root;
|
|
GdkPixbuf *new_pixbuf;
|
|
|
|
root = GDK_ROOT_PARENT ();
|
|
new_pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
|
|
0, 0, 0, 0, evt->width, evt->height);
|
|
gtk_object_set_data (GTK_OBJECT (drawing_area), "pixbuf", new_pixbuf);
|
|
gdk_pixbuf_unref (pixbuf);
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
GdkWindow *root;
|
|
GtkWidget *window;
|
|
GtkWidget *vbox;
|
|
GtkWidget *drawing_area;
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
|
|
|
root = GDK_ROOT_PARENT ();
|
|
pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
|
|
0, 0, 0, 0, 150, 160);
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
|
GTK_SIGNAL_FUNC (close_app), NULL);
|
|
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
|
GTK_SIGNAL_FUNC (close_app), NULL);
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
drawing_area = gtk_drawing_area_new ();
|
|
gtk_widget_set_usize (GTK_WIDGET (drawing_area),
|
|
gdk_pixbuf_get_width (pixbuf),
|
|
gdk_pixbuf_get_height (pixbuf));
|
|
gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
|
|
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event",
|
|
GTK_SIGNAL_FUNC (configure_cb), NULL);
|
|
gtk_signal_connect (GTK_OBJECT (window), "key_press_event",
|
|
GTK_SIGNAL_FUNC (keypress_check), drawing_area);
|
|
gtk_object_set_data (GTK_OBJECT (drawing_area), "pixbuf", pixbuf);
|
|
gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show_all (window);
|
|
gtk_main ();
|
|
return 0;
|
|
}
|