~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-separator-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
#include <math.h>
 
21
#include <string.h>
 
22
#include <cairo.h>
 
23
#include <stdlib.h>
 
24
 
 
25
#ifdef HAVE_GLITZ
 
26
#include <gdk/gdkx.h>
 
27
#include <glitz-glx.h>
 
28
#include <cairo-glitz.h>
 
29
#endif
 
30
 
 
31
#include "cairo-dock-icons.h"
 
32
#include "cairo-dock-draw.h"
 
33
#include "cairo-dock-load.h"
 
34
#include "cairo-dock-surface-factory.h"
 
35
#include "cairo-dock-log.h"
 
36
#include "cairo-dock-internal-icons.h"
 
37
#include "cairo-dock-dock-factory.h"
 
38
#include "cairo-dock-separator-factory.h"
 
39
#include "cairo-dock-icon-loader.h"
 
40
#include "cairo-dock-separator-manager.h"
 
41
 
 
42
 
 
43
cairo_surface_t *cairo_dock_create_separator_surface (int iWidth, int iHeight)
 
44
{
 
45
        cairo_surface_t *pNewSurface = NULL;
 
46
        if (myIcons.cSeparatorImage == NULL)
 
47
        {
 
48
                pNewSurface = cairo_dock_create_blank_surface (
 
49
                        iWidth,
 
50
                        iHeight);
 
51
        }
 
52
        else
 
53
        {
 
54
                gchar *cImagePath = cairo_dock_generate_file_path (myIcons.cSeparatorImage);
 
55
                
 
56
                pNewSurface = cairo_dock_create_surface_from_image_simple (cImagePath,
 
57
                        iWidth,
 
58
                        iHeight);
 
59
                
 
60
                g_free (cImagePath);
 
61
        }
 
62
        
 
63
        return pNewSurface;
 
64
}
 
65
 
 
66
 
 
67
static void _load_separator (Icon *icon)
 
68
{
 
69
        int iWidth = icon->iImageWidth;
 
70
        int iHeight = icon->iImageHeight;
 
71
        
 
72
        icon->pIconBuffer = cairo_dock_create_separator_surface (
 
73
                iWidth,
 
74
                iHeight);
 
75
}
 
76
 
 
77
Icon *cairo_dock_create_separator_icon (int iSeparatorType, CairoDock *pDock)
 
78
{
 
79
        //g_print ("%s ()\n", __func__);
 
80
        if ((iSeparatorType & 1) && ! myIcons.iSeparateIcons)
 
81
                return NULL;
 
82
        
 
83
        //\____________ On cree l'icone.
 
84
        Icon *icon = cairo_dock_new_separator_icon (iSeparatorType);
 
85
        icon->iface.load_image = _load_separator;
 
86
        
 
87
        //\____________ On remplit ses buffers.
 
88
        if (pDock)
 
89
                cairo_dock_trigger_load_icon_buffers (icon, CAIRO_CONTAINER (pDock));
 
90
 
 
91
        return icon;
 
92
}
 
93
 
 
94
 
 
95
void cairo_dock_insert_automatic_separator_in_dock (int iSeparatorType, const gchar *cParentDockName, CairoDock *pDock)
 
96
{
 
97
        Icon *pSeparatorIcon = cairo_dock_create_separator_icon (iSeparatorType, pDock);
 
98
        if (pSeparatorIcon != NULL)
 
99
        {
 
100
                pSeparatorIcon->cParentDockName = g_strdup (cParentDockName);
 
101
                pDock->icons = g_list_insert_sorted (pDock->icons,
 
102
                        pSeparatorIcon,
 
103
                        (GCompareFunc) cairo_dock_compare_icons_order);
 
104
                pSeparatorIcon->fWidth *= pDock->container.fRatio;
 
105
                pSeparatorIcon->fHeight *= pDock->container.fRatio;
 
106
                pDock->fFlatDockWidth += myIcons.iIconGap + pSeparatorIcon->fWidth;
 
107
                ///pDock->iMaxIconHeight = MAX (pDock->iMaxIconHeight, pSeparatorIcon->fHeight);
 
108
        }
 
109
}