File: main.c

package info (click to toggle)
ion2 20040729-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,828 kB
  • ctags: 3,466
  • sloc: ansic: 28,432; makefile: 473; sh: 230; perl: 16
file content (137 lines) | stat: -rw-r--r-- 3,030 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 * ion/floatws/main.c
 *
 * Copyright (c) Tuomo Valkonen 1999-2004. 
 *
 * Ion is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 */

#include <ioncore/binding.h>
#include <ioncore/conf-bindings.h>
#include <ioncore/readconfig.h>
#include <ioncore/genframep.h>
#include <ioncore/genframe-pointer.h>
#include <ioncore/reginfo.h>
#include <ioncore/hooks.h>
#include <ioncore/clientwin.h>
#include <ioncore/extl.h>

#include "floatws.h"
#include "floatframe.h"


/*{{{ Module information */


#include "../version.h"

char floatws_module_ion_api_version[]=ION_API_VERSION;


/*}}}*/


/*{{{ Bindmaps w/ config */


WBindmap floatws_bindmap=BINDMAP_INIT;
WBindmap floatframe_bindmap=BINDMAP_INIT;
WBindmap floatframe_moveres_bindmap=BINDMAP_INIT;


static StringIntMap frame_areas[]={
    {"border",         WGENFRAME_AREA_BORDER},
    {"tab",         WGENFRAME_AREA_TAB},
    {"empty_tab",     WGENFRAME_AREA_TAB},
    {"client",         WGENFRAME_AREA_CLIENT},
    END_STRINGINTMAP
};


/*EXTL_DOC
 * Sets up bindings for WFloatFrames.
 */
EXTL_EXPORT
bool floatframe_bindings(ExtlTab tab)
{
    return process_bindings(&floatframe_bindmap, frame_areas, tab);
}


/*EXTL_DOC
 * Sets up bindings for move/resize mode of WFloatFrames.
 */
EXTL_EXPORT
bool floatframe_moveres_bindings(ExtlTab tab)
{
    return process_bindings(&floatframe_moveres_bindmap, NULL, tab);
}


/*EXTL_DOC
 * Sets up bindings available in all objects on WFloatWS:s.
 */
EXTL_EXPORT
void floatws_bindings(ExtlTab tab)
{
    process_bindings(&floatws_bindmap, NULL, tab);
}


/*}}}*/


/*{{{ Init & deinit */


extern bool floatws_module_register_exports();
extern bool floatws_module_unregister_exports();


void floatws_module_deinit()
{
    REMOVE_HOOK(add_clientwin_alt, add_clientwin_floatws_transient);

    floatws_module_unregister_exports();
    deinit_bindmap(&floatws_bindmap);
    deinit_bindmap(&floatframe_bindmap);
    deinit_bindmap(&floatframe_moveres_bindmap);
    unregister_region_class(&OBJDESCR(WFloatWS));
    unregister_region_class(&OBJDESCR(WFloatFrame));
}



bool floatws_module_init()
{
    if(!floatws_module_register_exports()){
        warn_obj("floatws module", "failed to register functions.");
        goto err;
    }
    
    if(!register_region_class(&OBJDESCR(WFloatWS),
                              (WRegionSimpleCreateFn*) create_floatws,
                              (WRegionLoadCreateFn*) floatws_load) ||
       !register_region_class(&OBJDESCR(WFloatFrame), NULL,
                              (WRegionLoadCreateFn*) floatframe_load)){
        warn_obj("floatws module", "failed to register classes.");
        goto err;
    }

    read_config("floatws");
    
    ADD_HOOK(add_clientwin_alt, add_clientwin_floatws_transient);

    return TRUE;
    
err:
    floatws_module_deinit();
    return FALSE;
}


/*}}}*/