2
* Copyright (c) 2010 Mike Qin <mikeandmore@gmail.com>
4
* The contents of this file are subject to the terms of either the GNU Lesser
5
* General Public License Version 2.1 only ("LGPL") or the Common Development and
6
* Distribution License ("CDDL")(collectively, the "License"). You may not use this
7
* file except in compliance with the License. You can obtain a copy of the CDDL at
8
* http://www.opensource.org/licenses/cddl1.php and a copy of the LGPLv2.1 at
9
* http://www.opensource.org/licenses/lgpl-license.php. See the License for the
10
* specific language governing permissions and limitations under the License. When
11
* distributing the software, include this License Header Notice in each file and
12
* include the full text of the License in the License file as well as the
15
* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
17
* For Covered Software in this distribution, this License shall be governed by the
18
* laws of the State of California (excluding conflict-of-law provisions).
19
* Any litigation relating to this License shall be subject to the jurisdiction of
20
* the Federal Courts of the Northern District of California and the state courts
21
* of the State of California, with venue lying in Santa Clara County, California.
25
* If you wish your version of this file to be governed by only the CDDL or only
26
* the LGPL Version 2.1, indicate your decision by adding "[Contributor]" elects to
27
* include this software in this distribution under the [CDDL or LGPL Version 2.1]
28
* license." If you don't indicate a single choice of license, a recipient has the
29
* option to distribute your version of this file under either the CDDL or the LGPL
30
* Version 2.1, or to extend the choice of license to its licensees as provided
31
* above. However, if you add LGPL Version 2.1 code and therefore, elected the LGPL
32
* Version 2 license, then the option applies only if the new code is made subject
33
* to such option by the copyright holder.
43
static skin_info_t* info;
44
static char* skin_name;
45
static skin_window_t* icbar_wind;
46
static skin_button_t* icbar_status_btn;
47
static skin_button_t* icbar_full_btn;
48
static skin_button_t* icbar_punc_btn;
51
toggle_english(GtkWidget* wid, GdkEventButton* evt, void* userdata)
53
icmgr_toggle_english();
58
toggle_full(GtkWidget* wid, GdkEventButton* evt, void* userdata)
65
toggle_punc(GtkWidget* wid, GdkEventButton* evt, void* userdata)
72
icbar_on_release(GtkWidget* wid, GdkEventMotion* evt, void* userdata)
75
gtk_window_get_position(GTK_WINDOW(wid), &(pos.x), &(pos.y));
76
settings_set(ICBAR_POS, &pos);
80
icmgr_skin_init(const char* name)
82
info = ui_skin_new(name);
83
if (!info) return FALSE;
84
skin_name = strdup(name);
85
icbar_wind = skin_window_new(GTK_WINDOW(ui_create_window()),
86
info->icbar_background,
88
skin_window_set_drag_to_move(icbar_wind, TRUE);
90
skin_window_set_release_cb(icbar_wind, G_CALLBACK(icbar_on_release), NULL);
92
/* creating the buttons */
93
icbar_status_btn = skin_button_new(info->eng_btn.normal1,
94
info->eng_btn.highlight1,
95
info->eng_btn.pressdown1);
96
icbar_full_btn = skin_button_new(info->full_btn.normal1,
97
info->full_btn.highlight1,
98
info->full_btn.pressdown1);
99
icbar_punc_btn = skin_button_new(info->punc_btn.normal1,
100
info->punc_btn.highlight1,
101
info->punc_btn.pressdown1);
103
/* setting up events */
104
skin_button_set_release_cb(icbar_status_btn,
105
G_CALLBACK(toggle_english), NULL);
106
skin_button_set_release_cb(icbar_full_btn,
107
G_CALLBACK(toggle_full), NULL);
108
skin_button_set_release_cb(icbar_punc_btn,
109
G_CALLBACK(toggle_punc), NULL);
111
/* adding the buttons to the icbar */
112
skin_window_add_button(icbar_wind, icbar_status_btn, info->eng_btn.x,
114
skin_window_add_button(icbar_wind, icbar_full_btn, info->full_btn.x,
116
skin_window_add_button(icbar_wind, icbar_punc_btn, info->punc_btn.x,
122
toggle_mode(gboolean mode, skin_button_t* btn, skin_button_info_t* info)
125
skin_button_set_image(btn, info->normal1, info->highlight1,
128
skin_button_set_image(btn, info->normal2, info->highlight2,
134
icmgr_skin_refresh(void)
136
if (settings_get_int(HIDE_ICBAR)) {
137
gtk_widget_hide(icbar_wind->widget);
140
IC* ic = icmgr_get_current();
141
if (ic == NULL || !ic->is_enabled) {
142
gtk_widget_hide(GTK_WIDGET(icbar_wind->widget));
145
toggle_mode(ic->is_english, icbar_status_btn, &(info->eng_btn));
146
toggle_mode(ic->is_full, icbar_full_btn, &(info->full_btn));
147
toggle_mode(ic->is_chn_punc, icbar_punc_btn, &(info->punc_btn));
151
gtk_window_get_size(GTK_WINDOW(icbar_wind->widget), &width, &height);
152
settings_get(ICBAR_POS, &pos);
153
adjust_position(&(pos.x), &(pos.y), width, height);
154
/* write back the adjustion */
155
settings_set(ICBAR_POS, &pos);
157
gtk_window_move(GTK_WINDOW(icbar_wind->widget), pos.x, pos.y);
158
gtk_widget_show(icbar_wind->widget);
162
icmgr_skin_dispose(void)
164
ui_skin_destroy(info);
166
skin_button_destroy(icbar_status_btn);
167
skin_button_destroy(icbar_full_btn);
168
skin_button_destroy(icbar_punc_btn);
169
skin_window_destroy(icbar_wind);
173
icmgr_skin_get_name(void)
179
.get_name = icmgr_skin_get_name,
180
.init = icmgr_skin_init,
181
.refresh = icmgr_skin_refresh,
182
.dispose = icmgr_skin_dispose,