]>
Dogcows Code - chaz/tint2/blob - src/taskbar/taskbarname.c
d1eb34e11dc22010ee09f9222f8b16d90f916c9a
1 /**************************************************************************
5 * Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 **************************************************************************/
21 #include <X11/Xutil.h>
22 #include <X11/Xatom.h>
33 #include "taskbarname.h"
35 int taskbarname_enabled
;
36 PangoFontDescription
*taskbarname_font_desc
;
37 Color taskbarname_font
;
40 void default_taskbarname()
42 taskbarname_enabled
= 0;
43 taskbarname_font_desc
= 0;
47 void init_taskbarname_panel(void *p
)
49 Panel
*panel
=(Panel
*)p
;
53 if (!taskbarname_enabled
) return;
55 for (j
=0 ; j
< panel
->nb_desktop
; j
++) {
56 tskbar
= &panel
->taskbar
[j
];
57 memcpy(&tskbar
->bar_name
.area
, &panel
->g_taskbar
.area_name
, sizeof(Area
));
58 tskbar
->bar_name
.area
.parent
= tskbar
;
59 if (j
== server
.desktop
)
60 tskbar
->bar_name
.area
.bg
= panel
->g_taskbar
.background_name
[TASKBAR_ACTIVE
];
62 tskbar
->bar_name
.area
.bg
= panel
->g_taskbar
.background_name
[TASKBAR_NORMAL
];
63 tskbar
->bar_name
.name
= g_strdup_printf("%d", j
+1);
65 // append the name at the beginning of taskbar
66 tskbar
->area
.list
= g_slist_append(tskbar
->area
.list
, &tskbar
->bar_name
);
71 void cleanup_taskbarname()
77 for (i
=0 ; i
< nb_panel
; i
++) {
79 for (j
=0 ; j
< panel
->nb_desktop
; j
++) {
80 tskbar
= &panel
->taskbar
[j
];
81 if (tskbar
->bar_name
.name
) g_free(tskbar
->bar_name
.name
);
82 free_area (&tskbar
->bar_name
.area
);
83 for (k
=0; k
<TASKBAR_STATE_COUNT
; ++k
) {
84 if (tskbar
->bar_name
.state_pix
[k
]) XFreePixmap(server
.dsp
, tskbar
->bar_name
.state_pix
[k
]);
86 tskbar
->area
.list
= g_slist_remove(tskbar
->area
.list
, &tskbar
->bar_name
);
92 void draw_taskbarname (void *obj
, cairo_t
*c
)
94 Taskbarname
*taskbar_name
= obj
;
97 layout
= pango_cairo_create_layout (c
);
100 pango_layout_set_font_description (layout
, taskbarname_font_desc
);
101 pango_layout_set_width (layout
, taskbar_name
->area
.width
* PANGO_SCALE
);
102 pango_layout_set_alignment (layout
, PANGO_ALIGN_CENTER
);
103 pango_layout_set_text (layout
, taskbar_name
->name
, strlen(taskbar_name
->name
));
105 cairo_set_source_rgba (c
, taskbarname_font
.color
[0], taskbarname_font
.color
[1], taskbarname_font
.color
[2], taskbarname_font
.alpha
);
107 pango_cairo_update_layout (c
, layout
);
108 cairo_move_to (c
, 0, taskbar_name
->posy
);
109 pango_cairo_show_layout (c
, layout
);
111 g_object_unref (layout
);
112 printf("draw_taskbarname %s ******************************\n", taskbar_name
->name
);
116 int resize_taskbarname(void *obj
)
118 Taskbarname
*taskbar_name
= (Taskbar
*)obj
;
119 Panel
*panel
= taskbar_name
->area
.panel
;
120 int name_height
, name_width
, name_height_ink
;
123 taskbar_name
->area
.redraw
= 1;
124 get_text_size2(taskbarname_font_desc
, &name_height_ink
, &name_height
, &name_width
, panel
->area
.height
, panel
->area
.width
, taskbar_name
->name
, strlen(taskbar_name
->name
));
126 if (panel_horizontal
) {
127 int new_size
= name_width
+ (2* (taskbar_name
->area
.paddingxlr
+ taskbar_name
->area
.bg
->border
.width
));
128 if (new_size
!= taskbar_name
->area
.width
) {
129 taskbar_name
->area
.width
= new_size
;
130 taskbar_name
->posy
= (taskbar_name
->area
.height
- name_height
) / 2;
135 int new_size
= name_height
+ (2 * (taskbar_name
->area
.paddingxlr
+ taskbar_name
->area
.bg
->border
.width
));
136 if (new_size
!= taskbar_name
->area
.height
) {
137 taskbar_name
->area
.height
= new_size
;
138 taskbar_name
->posy
= (taskbar_name
->area
.height
- name_height
) / 2;
This page took 0.043507 seconds and 3 git commands to generate.