grim/guifications3
Clone
Summary
Browse
Changes
Graph
include gflib/gf_intl.h since it's no longer included via gf_lib.h
cmake
2010-12-20, Gary Kramlich
1eb207f1d7ef
include gflib/gf_intl.h since it's no longer included via gf_lib.h
/*
* 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/>.
*/
#if HAVE_CONFIG_H
#
include
<config.h>
#endif
/* HAVE_CONFIG_H */
#include
<glib-object.h>
#include
<gflib-ui/gf_primitives.h>
/******************************************************************************
* GfLine Stuff
*****************************************************************************/
static
GfLine
*
gf_line_copy
(
const
GfLine
*
line
)
{
GfLine
*
l
=
g_new0
(
GfLine
,
1
);
*
l
=
*
line
;
return
l
;
}
GType
gf_line_get_gtype
(
void
)
{
static
GType
type
=
0
;
if
(
type
==
0
)
{
type
=
g_boxed_type_register_static
(
"GfLine"
,
(
GBoxedCopyFunc
)
gf_line_copy
,
(
GBoxedFreeFunc
)
g_free
);
}
return
type
;
}
/******************************************************************************
* GfPoint Stuff
*****************************************************************************/
static
GfPoint
*
gf_point_copy
(
const
GfPoint
*
point
)
{
GfPoint
*
p
=
g_new0
(
GfPoint
,
1
);
*
p
=
*
point
;
return
p
;
}
GType
gf_point_get_gtype
(
void
)
{
static
GType
type
=
0
;
if
(
type
==
0
)
{
type
=
g_boxed_type_register_static
(
"GfPoint"
,
(
GBoxedCopyFunc
)
gf_point_copy
,
(
GBoxedFreeFunc
)
g_free
);
}
return
type
;
}
/******************************************************************************
* GfRectangle Stuff
*****************************************************************************/
/**
* gf_rectangle_intersect:
* @src1: A #GfRectangle.
* @src2: A #GfRectangle.
* @dest: The return address for the intersection of @src1 and @src2.
*
* Calculates the intersection of @src1 and @src2.
*
* Return Value: TRUE if @src1 and @src2 intersect, FALSE if they don't.
*/
gboolean
gf_rectangle_intersect
(
const
GfRectangle
*
src1
,
const
GfRectangle
*
src2
,
GfRectangle
*
dest
)
{
gint
dx
,
dy
,
dw
,
dh
;
gboolean
ret
=
FALSE
;
g_return_val_if_fail
(
src1
,
FALSE
);
g_return_val_if_fail
(
src2
,
FALSE
);
g_return_val_if_fail
(
dest
,
FALSE
);
dx
=
MAX
(
src1
->
x
,
src2
->
x
);
dy
=
MAX
(
src1
->
y
,
src2
->
y
);
dw
=
MAX
(
src1
->
x
+
src1
->
width
,
src2
->
x
+
src2
->
width
)
-
dx
;
dh
=
MAX
(
src1
->
y
+
src1
->
height
,
src2
->
y
+
src2
->
height
)
-
dy
;
if
(
dw
>
0
&&
dh
>
0
)
{
dest
->
x
=
dx
;
dest
->
y
=
dy
;
dest
->
width
=
dw
;
dest
->
height
=
dh
;
ret
=
TRUE
;
}
else
{
dest
->
x
=
dest
->
y
=
0
;
dest
->
width
=
dest
->
height
=
0
;
}
return
ret
;
}
/**
* gf_rectangle_union:
* @src1: A #GfRectangle.
* @src2: A #GfRectangle.
* @dest: The return address for the union of @src1 and @src2.
*
* Calculates the smallest #GfRectangle that includes @src1 and @src2.
*/
void
gf_rectangle_union
(
const
GfRectangle
*
src1
,
const
GfRectangle
*
src2
,
GfRectangle
*
dest
)
{
g_return_if_fail
(
src1
);
g_return_if_fail
(
src2
);
g_return_if_fail
(
dest
);
dest
->
x
=
MIN
(
src1
->
x
,
src2
->
x
);
dest
->
y
=
MIN
(
src1
->
y
,
src2
->
y
);
dest
->
width
=
MAX
(
src1
->
x
+
src1
->
width
,
src2
->
x
+
src2
->
width
)
-
dest
->
x
;
dest
->
height
=
MAX
(
src1
->
y
+
src1
->
height
,
src2
->
y
+
src2
->
height
)
-
dest
->
y
;
}
static
GfRectangle
*
gf_rectangle_copy
(
const
GfRectangle
*
rectangle
)
{
GfRectangle
*
ret
=
g_new0
(
GfRectangle
,
1
);
*
ret
=
*
rectangle
;
return
ret
;
}
GType
gf_rectangle_get_gtype
(
void
)
{
static
GType
type
=
0
;
if
(
type
==
0
)
{
type
=
g_boxed_type_register_static
(
"GfRectangle"
,
(
GBoxedCopyFunc
)
gf_rectangle_copy
,
(
GBoxedFreeFunc
)
g_free
);
}
return
type
;
}
/******************************************************************************
* GfSegment Stuff
*****************************************************************************/
static
GfSegment
*
gf_segment_copy
(
const
GfSegment
*
segment
)
{
GfSegment
*
seg
=
g_new0
(
GfSegment
,
1
);
*
seg
=
*
segment
;
return
seg
;
}
GType
gf_segment_get_gtype
(
void
)
{
static
GType
type
=
0
;
if
(
type
==
0
)
{
type
=
g_boxed_type_register_static
(
"GfSegment"
,
(
GBoxedCopyFunc
)
gf_segment_copy
,
(
GBoxedFreeFunc
)
g_free
);
}
return
type
;
}