~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-internal-position.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 "cairo-dock-modules.h"
 
21
#include "cairo-dock-dock-manager.h"
 
22
#include "cairo-dock-dock-factory.h"
 
23
#include "cairo-dock-dock-facility.h"
 
24
#include "cairo-dock-log.h"
 
25
#include "cairo-dock-X-utilities.h"
 
26
#include "cairo-dock-X-manager.h"
 
27
#include "cairo-dock-internal-accessibility.h"
 
28
#define _INTERNAL_MODULE_
 
29
#include "cairo-dock-internal-position.h"
 
30
 
 
31
CairoConfigPosition myPosition;
 
32
extern CairoDock *g_pMainDock;
 
33
extern CairoDockDesktopGeometry g_desktopGeometry;
 
34
 
 
35
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigPosition *pPosition)
 
36
{
 
37
        gboolean bFlushConfFileNeeded = FALSE;
 
38
        
 
39
        pPosition->iGapX = cairo_dock_get_integer_key_value (pKeyFile, "Position", "x gap", &bFlushConfFileNeeded, 0, NULL, NULL);
 
40
        pPosition->iGapY = cairo_dock_get_integer_key_value (pKeyFile, "Position", "y gap", &bFlushConfFileNeeded, 0, NULL, NULL);
 
41
 
 
42
        pPosition->iScreenBorder = cairo_dock_get_integer_key_value (pKeyFile, "Position", "screen border", &bFlushConfFileNeeded, 0, NULL, NULL);
 
43
        if (pPosition->iScreenBorder >= CAIRO_DOCK_NB_POSITIONS)
 
44
                pPosition->iScreenBorder = 0;
 
45
 
 
46
        pPosition->fAlign = cairo_dock_get_double_key_value (pKeyFile, "Position", "alignment", &bFlushConfFileNeeded, 0.5, NULL, NULL);
 
47
        
 
48
        pPosition->bUseXinerama = cairo_dock_get_boolean_key_value (pKeyFile, "Position", "xinerama", &bFlushConfFileNeeded, 0, NULL, NULL);
 
49
        if (pPosition->bUseXinerama && ! cairo_dock_xinerama_is_available ())
 
50
        {
 
51
                cd_warning ("Sorry but either your X server does not have the Xinerama extension, or your version of Cairo-Dock was not built with the support of Xinerama.\n You can't place the dock on a particular screen");
 
52
                pPosition->bUseXinerama = FALSE;
 
53
        }
 
54
        if (pPosition->bUseXinerama)
 
55
                pPosition->iNumScreen = cairo_dock_get_integer_key_value (pKeyFile, "Position", "num screen", &bFlushConfFileNeeded, 0, NULL, NULL);
 
56
 
 
57
        return bFlushConfFileNeeded;
 
58
}
 
59
 
 
60
 
 
61
static void reload (CairoConfigPosition *pPrevPosition, CairoConfigPosition *pPosition)
 
62
{
 
63
        //g_print ("%s (%d;%d)\n", __func__, pPosition->iGapX, pPosition->iGapY);
 
64
        CairoDock *pDock = g_pMainDock;
 
65
        
 
66
        if (pPosition->bUseXinerama)
 
67
        {
 
68
                pDock->iNumScreen = pPosition->iNumScreen;
 
69
                cairo_dock_get_screen_offsets (pPosition->iNumScreen, &pDock->iScreenOffsetX, &pDock->iScreenOffsetY);
 
70
        }
 
71
        else  // on n'utilise pas Xinerama.
 
72
        {
 
73
                pDock->iNumScreen = pDock->iScreenOffsetX = pDock->iScreenOffsetY = 0;
 
74
                if (pPrevPosition->bUseXinerama)  // mais on l'utilisait avant, il faut donc recuperer les dimensions de l'ecran.
 
75
                {
 
76
                        g_desktopGeometry.iScreenWidth[CAIRO_DOCK_HORIZONTAL] = g_desktopGeometry.iXScreenWidth[CAIRO_DOCK_HORIZONTAL];
 
77
                        g_desktopGeometry.iScreenHeight[CAIRO_DOCK_HORIZONTAL] = g_desktopGeometry.iXScreenHeight[CAIRO_DOCK_HORIZONTAL];
 
78
                        g_desktopGeometry.iScreenWidth[CAIRO_DOCK_VERTICAL] = g_desktopGeometry.iScreenHeight[CAIRO_DOCK_HORIZONTAL];
 
79
                        g_desktopGeometry.iScreenHeight[CAIRO_DOCK_VERTICAL] = g_desktopGeometry.iScreenWidth[CAIRO_DOCK_HORIZONTAL];
 
80
                }
 
81
        }
 
82
        
 
83
        if (pPosition->bUseXinerama != pPrevPosition->bUseXinerama)
 
84
        {
 
85
                cairo_dock_reposition_root_docks (TRUE);  // on replace tous les docks racines sauf le main dock, puisque c'est fait apres.
 
86
        }
 
87
        
 
88
        CairoDockTypeHorizontality bWasHorizontal = pDock->container.bIsHorizontal;
 
89
        if (pPosition->iScreenBorder != pPrevPosition->iScreenBorder)
 
90
        {
 
91
                cairo_dock_set_dock_orientation (pDock, pPosition->iScreenBorder);
 
92
                /**switch (pPosition->iScreenBorder)
 
93
                {
 
94
                        case CAIRO_DOCK_BOTTOM :
 
95
                                pDock->container.bIsHorizontal = CAIRO_DOCK_HORIZONTAL;
 
96
                                pDock->container.bDirectionUp = TRUE;
 
97
                        break;
 
98
                        case CAIRO_DOCK_TOP :
 
99
                                pDock->container.bIsHorizontal = CAIRO_DOCK_HORIZONTAL;
 
100
                                pDock->container.bDirectionUp = FALSE;
 
101
                        break;
 
102
                        case CAIRO_DOCK_RIGHT :
 
103
                                pDock->container.bIsHorizontal = CAIRO_DOCK_VERTICAL;
 
104
                                pDock->container.bDirectionUp = TRUE;
 
105
                        break;
 
106
                        case CAIRO_DOCK_LEFT :
 
107
                                pDock->container.bIsHorizontal = CAIRO_DOCK_VERTICAL;
 
108
                                pDock->container.bDirectionUp = FALSE;
 
109
                        break;
 
110
                }
 
111
                cairo_dock_update_dock_size (pDock);  // si bHorizonalDock a change, la taille max a change aussi.
 
112
                cairo_dock_synchronize_sub_docks_orientation (pDock, FALSE);
 
113
                cairo_dock_reload_buffers_in_all_docks (TRUE);*/
 
114
        }
 
115
        cairo_dock_update_dock_size (pDock);  // si l'ecran ou l'orientation a change, la taille max a change aussi.
 
116
        
 
117
        pDock->iGapX = pPosition->iGapX;
 
118
        pDock->iGapY = pPosition->iGapY;
 
119
        pDock->fAlign = pPosition->fAlign;
 
120
        cairo_dock_calculate_dock_icons (pDock);
 
121
        cairo_dock_move_resize_dock (pDock);
 
122
        if (bWasHorizontal != pDock->container.bIsHorizontal)
 
123
                pDock->container.iWidth --;  // la taille dans le referentiel du dock ne change pas meme si on change d'horizontalite, par contre la taille de la fenetre change. On introduit donc un biais ici pour forcer le configure-event a faire son travail, sinon ca fausse le redraw.
 
124
        gtk_widget_queue_draw (pDock->container.pWidget);
 
125
}
 
126
 
 
127
 
 
128
DEFINE_PRE_INIT (Position)
 
129
{
 
130
        pModule->cModuleName = "Position";
 
131
        pModule->cTitle = N_("Position");
 
132
        pModule->cIcon = "icon-position.svg";
 
133
        pModule->cDescription = N_("Set the position of the main dock.");
 
134
        pModule->iCategory = CAIRO_DOCK_CATEGORY_BEHAVIOR;
 
135
        pModule->iSizeOfConfig = sizeof (CairoConfigPosition);
 
136
        pModule->iSizeOfData = 0;
 
137
        
 
138
        pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
 
139
        pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
 
140
        pModule->reset_config = NULL;
 
141
        pModule->reset_data = NULL;
 
142
        
 
143
        pModule->pConfig = (CairoInternalModuleConfigPtr) &myPosition;
 
144
        pModule->pData = NULL;
 
145
}