grim/guifications3
Clone
Summary
Browse
Changes
Graph
Closing this branch since we moved to "default" for it a while ago now
org.guifications.gf3
2009-12-06, Gary Kramlich
3707becf4df7
Closing this branch since we moved to "default" for it a while ago now
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This test creates a GfImage from a file, and then tries to convert
* it into a GdkPixbuf and display it.
*/
#include
<gflib-gtk/gf_lib_gtk.h>
#include
<gtk/gtk.h>
static
void
delete_cb
(
GtkWidget
*
w
,
GdkEvent
*
e
,
gpointer
data
)
{
gtk_main_quit
();
}
gint
main
(
gint
argc
,
gchar
**
argv
)
{
GfImage
*
gf_image1
=
NULL
,
*
gf_image2
=
NULL
;
GtkWidget
*
window
=
NULL
,
*
gtk_image
=
NULL
,
*
box
=
NULL
,
*
frame
=
NULL
;
GdkPixbuf
*
pixbuf
=
NULL
;
const
guchar
*
data
=
NULL
;
gsize
data_sz
=
0
;
gf_lib_gtk_init
(
&
argc
,
&
argv
);
window
=
gtk_window_new
(
GTK_WINDOW_TOPLEVEL
);
g_signal_connect
(
window
,
"delete-event"
,
G_CALLBACK
(
delete_cb
),
NULL
);
box
=
gtk_hbox_new
(
TRUE
,
4
);
gtk_container_add
(
GTK_CONTAINER
(
window
),
box
);
/* create an image from file */
frame
=
gtk_frame_new
(
"File"
);
gtk_box_pack_start
(
GTK_BOX
(
box
),
frame
,
TRUE
,
TRUE
,
0
);
gf_image1
=
gf_image_new_from_file
(
"logo.png"
);
pixbuf
=
gf_gtk_image_to_pixbuf
(
gf_image1
,
NULL
);
gtk_image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
gtk_container_add
(
GTK_CONTAINER
(
frame
),
gtk_image
);
g_object_unref
(
pixbuf
);
/* create an image from data */
frame
=
gtk_frame_new
(
"Data"
);
gtk_box_pack_start
(
GTK_BOX
(
box
),
frame
,
TRUE
,
TRUE
,
0
);
data
=
gf_image_get_data
(
gf_image1
,
&
data_sz
);
gf_image2
=
gf_image_new_from_data
(
data
,
data_sz
);
pixbuf
=
gf_gtk_image_to_pixbuf
(
gf_image2
,
NULL
);
gtk_image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
g_object_unref
(
pixbuf
);
gtk_container_add
(
GTK_CONTAINER
(
frame
),
gtk_image
);
/* scale the image frm data */
frame
=
gtk_frame_new
(
"Scaled"
);
gtk_box_pack_start
(
GTK_BOX
(
box
),
frame
,
TRUE
,
TRUE
,
0
);
pixbuf
=
gf_gtk_image_to_scaled_pixbuf
(
gf_image2
,
64
,
64
,
NULL
);
gtk_image
=
gtk_image_new_from_pixbuf
(
pixbuf
);
g_object_unref
(
pixbuf
);
gtk_container_add
(
GTK_CONTAINER
(
frame
),
gtk_image
);
/* clean up */
g_object_unref
(
gf_image1
);
g_object_unref
(
gf_image2
);
/* show it all and run! */
gtk_widget_show_all
(
window
);
gtk_main
();
return
0
;
}