Changeset 5978 for branches/newosd
- Timestamp:
- 01/02/08 11:25:29 (11 months ago)
- Location:
- branches/newosd/src
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/newosd/src/iface.cpp
r5974 r5978 1 1 #include "iface.h" 2 3 #include <string>4 2 5 3 #include <licq_icqd.h> … … 11 9 aosd_set_transparency(aosd, TRANSPARENCY_COMPOSITE); 12 10 aosd_set_hide_upon_mouse_event(aosd, True); 13 aosd_set_renderer(aosd, 14 reinterpret_cast<AosdRenderer>(aosd_text_renderer), &trd); 11 aosd_set_renderer(aosd, aosd_text_renderer, &trd); 15 12 aosd_set_names(aosd, "OSD Plugin", "Licq"); 16 13 … … 27 24 trd.shadow.y_offset = 2; 28 25 trd.shadow.color = "black"; 29 trd.shadow.opacity = 127; 30 31 trd.fore.color = "green"; 26 trd.shadow.opacity = 192; 27 32 28 trd.fore.opacity = 255; 33 29 … … 50 46 void Iface::processSignal(CICQSignal* sig) 51 47 { 52 clearLayout(); 48 string msg = ""; 49 bool message = false; 53 50 54 51 switch (sig->Signal()) … … 64 61 break; 65 62 66 string msg = "";63 msg = u->GetAlias(); 67 64 68 65 switch (sig->SubSignal()) 69 66 { 70 67 case USER_STATUS: 71 msg = u->GetAlias();72 68 msg += " changed status to: "; 73 69 msg += u->StatusStr(); … … 78 74 case USER_EVENTS: 79 75 if (sig->Argument() < 0) 76 { 77 msg.clear(); 80 78 break; 79 } 81 80 82 81 if (sig->Argument() == 0) 83 82 { 84 msg = u->GetAlias();85 83 msg += " checked your auto-response"; 86 84 break; … … 91 89 if (ue == NULL) 92 90 break; 93 msg = setLayoutTag(u); 91 if (u->Secure()) // TODO config check 92 msg += " (S)"; 93 msg += ": "; 94 94 char* trans = gTranslator.ToUnicode(const_cast<char*>(ue->Text()), 95 95 u->UserEncoding()); 96 96 msg += trans; 97 97 delete[] trans; 98 message = true; 98 99 } 99 100 break; 100 101 101 102 default: 103 msg.clear(); 102 104 break; 103 105 } 104 106 105 107 gUserManager.DropUser(u); 106 pango_layout_set_text_aosd(trd.lay, const_cast<char*>(msg.c_str()));107 displayLayout();108 108 } 109 109 break; … … 118 118 break; 119 119 } 120 } 121 122 void Iface::clearLayout() 123 { 124 pango_layout_set_text(trd.lay, "", -1); 125 pango_layout_set_indent(trd.lay, 0); 120 121 if (!msg.empty()) 122 displayLayout(msg, message); 126 123 } 127 124 … … 180 177 } 181 178 182 const char* Iface::setLayoutTag(ICQUser* u) 183 { 184 string str = u->GetAlias(); 185 str += (true && u->Secure()) ? " (S)" : ""; 186 str += ": "; 187 188 int tag_width = 0; 189 190 pango_layout_set_text(trd.lay, str.c_str(), -1); 191 pango_layout_get_size(trd.lay, &tag_width, NULL); 192 pango_layout_set_indent(trd.lay, -tag_width); 193 194 return str.c_str(); 195 } 196 197 void Iface::displayLayout() 198 { 199 if (strlen(pango_layout_get_text(trd.lay)) == 0) 200 return; 179 void Iface::displayLayout(string& msg, bool message) 180 { 181 /* 182 string nl = "âš"; // U+2028 183 string::size_type pos = 0; 184 while ((pos = msg.find('\n', pos)) != string::npos) 185 msg.replace(pos, nl.length(), nl); 186 */ 187 pango_layout_set_text(trd.lay, const_cast<char*>(msg.c_str()), -1); 188 189 trd.fore.color = const_cast<char*>(message ? "green" : "gray"); 201 190 202 191 unsigned width, height; … … 205 194 206 195 aosd_set_position_with_offset(aosd, 207 COORDINATE_MINIMUM, COORDINATE_M INIMUM,196 COORDINATE_MINIMUM, COORDINATE_MAXIMUM, 208 197 width + 2 * trd.geom.x_offset + trd.shadow.x_offset, 209 198 height + 2 * trd.geom.y_offset + trd.shadow.y_offset, 210 80, 80);211 212 aosd_flash(aosd, 0, 1000, 150);199 80, -80); 200 201 aosd_flash(aosd, 0, 3000, 150); 213 202 } 214 203 -
branches/newosd/src/iface.h
r5974 r5978 2 2 #define IFACE_H 3 3 4 class CICQSignal; 5 class ICQUser; 4 #include <string> 6 5 7 extern "C"8 {9 6 #include <libaosd/aosd.h> 10 7 #include <libaosd/aosd-text.h> 11 8 #undef Status 12 } 9 10 class CICQSignal; 11 class ICQUser; 13 12 14 13 class Iface … … 29 28 30 29 const char* setLayoutTag(ICQUser* u); 31 void clearLayout(); 32 void displayLayout(); 30 void displayLayout(std::string& msg, bool message); 33 31 }; 34 32
