| 60 | | def on_openvolumecontrol_button_click(self, widget, ip): |
| 61 | | print_debug ( "on_openvolumecontrol_button_click() ip=%s" %(ip) ) |
| 62 | | cmd="PULSE_SERVER=\"%s\" pavucontrol" %(ip) |
| 63 | | if os.path.isdir("/dev/shm"): |
| 64 | | self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| 65 | | else: |
| 66 | | shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| 67 | | |
| 68 | | def on_openvolumemeter_button_click(self, widget, ip): |
| 69 | | print_debug ( "on_openvolumemeter_button_click() ip=%s" %(ip) ) |
| 70 | | cmd="PULSE_SERVER=\"%s\" pavumeter" %(ip) |
| 71 | | if os.path.isdir("/dev/shm"): |
| 72 | | self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| 73 | | else: |
| 74 | | shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| 75 | | |
| 76 | | def on_volumemanager_button_click(self, widget, ip): |
| 77 | | print_debug ( "on_volumemanager_button_click() ip=%s" %(ip) ) |
| 78 | | cmd="PULSE_SERVER=\"%s\" paman" %(ip) |
| 79 | | if os.path.isdir("/dev/shm"): |
| 80 | | self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| 81 | | else: |
| 82 | | shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| | 62 | # def on_openvolumecontrol_button_click(self, widget, ip): |
| | 63 | # print_debug ( "on_openvolumecontrol_button_click() ip=%s" %(ip) ) |
| | 64 | # cmd="PULSE_SERVER=\"%s\" pavucontrol" %(ip) |
| | 65 | # if os.path.isdir("/dev/shm"): |
| | 66 | # self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| | 67 | # else: |
| | 68 | # shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| | 69 | # |
| | 70 | # def on_openvolumemeter_button_click(self, widget, ip): |
| | 71 | # print_debug ( "on_openvolumemeter_button_click() ip=%s" %(ip) ) |
| | 72 | # cmd="PULSE_SERVER=\"%s\" pavumeter" %(ip) |
| | 73 | # if os.path.isdir("/dev/shm"): |
| | 74 | # self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| | 75 | # else: |
| | 76 | # shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| | 77 | # |
| | 78 | # def on_volumemanager_button_click(self, widget, ip): |
| | 79 | # print_debug ( "on_volumemanager_button_click() ip=%s" %(ip) ) |
| | 80 | # cmd="PULSE_SERVER=\"%s\" paman" %(ip) |
| | 81 | # if os.path.isdir("/dev/shm"): |
| | 82 | # self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| | 83 | # else: |
| | 84 | # shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| 227 | | def on_drag_data_received( self, widget, context, x, y, selection, targetType, dtime): |
| 228 | | files = selection.data.split('\n',1) |
| 229 | | start1=time() |
| 230 | | print_debug("on_drag_data_received() files=%s dtime=%s"%(files,dtime)) |
| 231 | | for f in files: |
| 232 | | if f: |
| 233 | | desktop = f.strip().replace('%20', ' ') |
| 234 | | break |
| 235 | | |
| 236 | | if desktop.startswith('file:///') and desktop.lower().endswith('.desktop') and os.path.isfile(desktop[7:]): |
| 237 | | print_debug("open_file() reading data from \"%s\"..." \ |
| 238 | | %(desktop[7:]) ) |
| 239 | | fd=file(desktop[7:], 'r') |
| 240 | | data=fd.readlines() |
| 241 | | fd.close() |
| 242 | | |
| 243 | | # try to load gnome theme with gconf |
| 244 | | mytheme=[] |
| 245 | | theme=self.main.common.get_icon_theme() |
| 246 | | print_debug("on_drag_data_received() gconf theme=%s"%theme) |
| 247 | | |
| 248 | | """ |
| 249 | | icons_path=["/usr/share/app-install/icons/", |
| 250 | | "/usr/share/icons/hicolor/48x48/apps/", |
| 251 | | "/usr/share/icons/hicolor/32x32/apps/", |
| 252 | | "/usr/share/icons/hicolor/24x24/apps/", |
| 253 | | "/usr/share/icons/gnome/48x48/apps/", |
| 254 | | "/usr/share/icons/gnome/32x32/apps/", |
| 255 | | "/usr/share/pixmaps/", |
| 256 | | "/usr/share/icons/gnome/32x32/devices/"] |
| 257 | | icons_extensions=[".png", "", ".xpm"] |
| 258 | | """ |
| 259 | | str_image="" |
| 260 | | files=[] |
| 261 | | |
| 262 | | if theme and os.path.isdir("/usr/share/icons/%s"%theme): |
| 263 | | files+=glob.glob("/usr/share/icons/%s/48x48/*.png"%(theme)) |
| 264 | | |
| 265 | | files+=glob.glob("/usr/share/icons/hicolor/48x48/*/*.png") + \ |
| 266 | | glob.glob("/usr/share/icons/gnome/48x48/*/*.png") + \ |
| 267 | | glob.glob("/usr/share/pixmaps/*png") +\ |
| 268 | | glob.glob("/usr/share/pixmaps/*xpm") |
| 269 | | |
| 270 | | for line in data: |
| 271 | | if line != '\n': |
| 272 | | if line.startswith("Exec="): |
| 273 | | line=line.replace('\n', '') |
| 274 | | action, str_exec=line.split("=",1) |
| 275 | | str_exec=str_exec.replace("%U","").replace("%u","").replace("%F","").replace("%f","").replace("%c","").replace("%i","").replace("%m","") |
| 276 | | elif line.startswith("Icon="): |
| 277 | | line=line.replace('\n', '') |
| 278 | | action, image_name=line.split("=",1) |
| 279 | | if not os.path.isfile(image_name): |
| 280 | | start2=time() |
| 281 | | for f in files: |
| 282 | | if image_name in f or image_name.replace('_', '-') in f: |
| 283 | | str_image=f |
| 284 | | crono(start2, "on_drag_data_received() ICON FOUND AT %s"%f ) |
| 285 | | break |
| 286 | | |
| 287 | | """ |
| 288 | | for ipath in icons_path: |
| 289 | | for ext in icons_extensions: |
| 290 | | print_debug("searching icon=%s in %s extension=%s" %(image_name, ipath, ext)) |
| 291 | | if os.path.isfile(ipath+image_name+ext): |
| 292 | | str_image=ipath+image_name+ext |
| 293 | | print_debug("image_name=%s found at %s, extension %s" %(image_name, ipath, ext)) |
| 294 | | break |
| 295 | | if str_image != "": break |
| 296 | | str_image="" |
| 297 | | """ |
| 298 | | else: |
| 299 | | str_image=image_name |
| 300 | | |
| 301 | | if len(str_exec) <1: |
| 302 | | shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| 303 | | else: |
| 304 | | if len(str_image) <1: |
| 305 | | print_debug("on_drag_data_received() image '%s' not found"%image_name) |
| 306 | | self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| 307 | | else: |
| 308 | | self.main.image_entry.set_from_file(str_image) |
| 309 | | self.main.ask_entry.set_text(str_exec) |
| 310 | | else: |
| 311 | | shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| 312 | | crono(start1, "on_drag_data_received() end" ) |
| 313 | | return True |
| | 231 | # def on_drag_data_received( self, widget, context, x, y, selection, targetType, dtime): |
| | 232 | # files = selection.data.split('\n',1) |
| | 233 | # start1=time() |
| | 234 | # print_debug("on_drag_data_received() files=%s dtime=%s"%(files,dtime)) |
| | 235 | # for f in files: |
| | 236 | # if f: |
| | 237 | # desktop = f.strip().replace('%20', ' ') |
| | 238 | # break |
| | 239 | # |
| | 240 | # if desktop.startswith('file:///') and desktop.lower().endswith('.desktop') and os.path.isfile(desktop[7:]): |
| | 241 | # print_debug("open_file() reading data from \"%s\"..." \ |
| | 242 | # %(desktop[7:]) ) |
| | 243 | # fd=file(desktop[7:], 'r') |
| | 244 | # data=fd.readlines() |
| | 245 | # fd.close() |
| | 246 | # |
| | 247 | # # try to load gnome theme with gconf |
| | 248 | # mytheme=[] |
| | 249 | # theme=self.main.common.get_icon_theme() |
| | 250 | # print_debug("on_drag_data_received() gconf theme=%s"%theme) |
| | 251 | # |
| | 252 | # """ |
| | 253 | # icons_path=["/usr/share/app-install/icons/", |
| | 254 | # "/usr/share/icons/hicolor/48x48/apps/", |
| | 255 | # "/usr/share/icons/hicolor/32x32/apps/", |
| | 256 | # "/usr/share/icons/hicolor/24x24/apps/", |
| | 257 | # "/usr/share/icons/gnome/48x48/apps/", |
| | 258 | # "/usr/share/icons/gnome/32x32/apps/", |
| | 259 | # "/usr/share/pixmaps/", |
| | 260 | # "/usr/share/icons/gnome/32x32/devices/"] |
| | 261 | # icons_extensions=[".png", "", ".xpm"] |
| | 262 | # """ |
| | 263 | # str_image="" |
| | 264 | # files=[] |
| | 265 | # |
| | 266 | # if theme and os.path.isdir("/usr/share/icons/%s"%theme): |
| | 267 | # files+=glob.glob("/usr/share/icons/%s/48x48/*.png"%(theme)) |
| | 268 | # |
| | 269 | # files+=glob.glob("/usr/share/icons/hicolor/48x48/*/*.png") + \ |
| | 270 | # glob.glob("/usr/share/icons/gnome/48x48/*/*.png") + \ |
| | 271 | # glob.glob("/usr/share/pixmaps/*png") +\ |
| | 272 | # glob.glob("/usr/share/pixmaps/*xpm") |
| | 273 | # |
| | 274 | # for line in data: |
| | 275 | # if line != '\n': |
| | 276 | # if line.startswith("Exec="): |
| | 277 | # line=line.replace('\n', '') |
| | 278 | # action, str_exec=line.split("=",1) |
| | 279 | # str_exec=str_exec.replace("%U","").replace("%u","").replace("%F","").replace("%f","").replace("%c","").replace("%i","").replace("%m","") |
| | 280 | # elif line.startswith("Icon="): |
| | 281 | # line=line.replace('\n', '') |
| | 282 | # action, image_name=line.split("=",1) |
| | 283 | # if not os.path.isfile(image_name): |
| | 284 | # start2=time() |
| | 285 | # for f in files: |
| | 286 | # if image_name in f or image_name.replace('_', '-') in f: |
| | 287 | # str_image=f |
| | 288 | # crono(start2, "on_drag_data_received() ICON FOUND AT %s"%f ) |
| | 289 | # break |
| | 290 | # |
| | 291 | # """ |
| | 292 | # for ipath in icons_path: |
| | 293 | # for ext in icons_extensions: |
| | 294 | # print_debug("searching icon=%s in %s extension=%s" %(image_name, ipath, ext)) |
| | 295 | # if os.path.isfile(ipath+image_name+ext): |
| | 296 | # str_image=ipath+image_name+ext |
| | 297 | # print_debug("image_name=%s found at %s, extension %s" %(image_name, ipath, ext)) |
| | 298 | # break |
| | 299 | # if str_image != "": break |
| | 300 | # str_image="" |
| | 301 | # """ |
| | 302 | # else: |
| | 303 | # str_image=image_name |
| | 304 | # |
| | 305 | # if len(str_exec) <1: |
| | 306 | # shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| | 307 | # else: |
| | 308 | # if len(str_image) <1: |
| | 309 | # print_debug("on_drag_data_received() image '%s' not found"%image_name) |
| | 310 | # self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| | 311 | # else: |
| | 312 | # self.main.image_entry.set_from_file(str_image) |
| | 313 | # self.main.ask_entry.set_text(str_exec) |
| | 314 | # else: |
| | 315 | # shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| | 316 | # crono(start1, "on_drag_data_received() end" ) |
| | 317 | # return True |
| 321 | | def on_ask_cancel_click(self, widget): |
| 322 | | self.main.ask.hide() |
| 323 | | self.main.ask_entry.set_text("") |
| 324 | | #desactivar arrastrar y soltar |
| 325 | | self.main.ask_fixed.hide() |
| 326 | | self.main.image_entry.hide() |
| 327 | | self.main.ask_dragdrop.hide() |
| 328 | | return |
| | 334 | # def askfor(self, mode="mess", msg="", users=[]): |
| | 335 | # self.ask_usernames=[] |
| | 336 | # if len(users) == 0 or users[0] == shared.NO_LOGIN_MSG: |
| | 337 | # shared.error_msg( _("Clients not connected") ) |
| | 338 | # return |
| | 339 | # else: |
| | 340 | # self.ask_usernames=users |
| | 341 | |
| | 342 | # users_txt="" |
| | 343 | # counter=1 |
| | 344 | # for user in self.ask_usernames: |
| | 345 | # users_txt+="%s, " %(user) |
| | 346 | # print_debug("askfor() counter=%s" %(counter) ) |
| | 347 | # if counter % 4 == 0: |
| | 348 | # users_txt+="\n" |
| | 349 | # counter=int(counter+1) |
| | 350 | |
| | 351 | # if users_txt[-2:] == "\n": users_txt=users_txt[:-2] |
| | 352 | # if users_txt[-2:] == ", ": users_txt=users_txt[:-2] |
| | 353 | # |
| | 354 | # if mode == "exec": |
| | 355 | # #activar arrastrar y soltar |
| | 356 | # self.main.ask_fixed.show() |
| | 357 | # self.main.ask_dragdrop.show() |
| | 358 | # self.main.image_entry.show() |
| | 359 | # self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| | 360 | # self.main.ask_label.set_markup( _("<b>Exec app in user(s) screen(s):</b>\n%s" ) %( users_txt ) ) |
| | 361 | # elif mode == "mess": |
| | 362 | # self.main.ask_label.set_markup( _("<b>Send a message to:</b>\n%s" ) %( users_txt ) ) |
| | 363 | # elif mode == "any": |
| | 364 | # self.main.ask_label.set_markup( msg ) |
| | 365 | # self.ask_mode=mode |
| | 366 | # self.main.ask.show() |
| | 367 | # return True |
| | 368 | |
| | 369 | # def exe_app_in_client(self, mode, timeout=0, msg="", users=[], connected_users=[]): |
| | 370 | # remote_cmd=("/usr/lib/tcos/session-cmd-send %s %s %s" %(mode.upper(), timeout, msg.replace("'", "´"))) |
| | 371 | # action="down-controller %s %s" %(mode, timeout) |
| | 372 | # print_debug("exe_app_in_client() usernames=%s" %users) |
| | 373 | # |
| | 374 | # if len(connected_users) != 0 and connected_users[0] != shared.NO_LOGIN_MSG: |
| | 375 | # newusernames=[] |
| | 376 | # for user in connected_users: |
| | 377 | # if user.find(":") != -1: |
| | 378 | # # we have a standalone user... |
| | 379 | # usern, ip = user.split(":") |
| | 380 | # self.main.xmlrpc.newhost(ip) |
| | 381 | # self.main.xmlrpc.DBus("exec", remote_cmd ) |
| | 382 | # else: |
| | 383 | # newusernames.append(user) |
| | 384 | # |
| | 385 | # result = self.main.dbus_action.do_exec( newusernames ,remote_cmd ) |
| | 386 | # |
| | 387 | # if not result: |
| | 388 | # shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) ) |
| | 389 | # |
| | 390 | # self.main.worker=shared.Workers(self.main, None, None) |
| | 391 | # self.main.worker.set_for_all_action(self.action_for_clients,\ |
| | 392 | # users, action ) |
| | 393 | # return |
| 330 | | def askfor(self, mode="mess", msg="", users=[]): |
| 331 | | self.ask_usernames=[] |
| 332 | | if len(users) == 0 or users[0] == shared.NO_LOGIN_MSG: |
| 333 | | shared.error_msg( _("Clients not connected") ) |
| 334 | | return |
| 335 | | else: |
| 336 | | self.ask_usernames=users |
| 337 | | |
| 338 | | users_txt="" |
| 339 | | counter=1 |
| 340 | | for user in self.ask_usernames: |
| 341 | | users_txt+="%s, " %(user) |
| 342 | | print_debug("askfor() counter=%s" %(counter) ) |
| 343 | | if counter % 4 == 0: |
| 344 | | users_txt+="\n" |
| 345 | | counter=int(counter+1) |
| 346 | | |
| 347 | | if users_txt[-2:] == "\n": users_txt=users_txt[:-2] |
| 348 | | if users_txt[-2:] == ", ": users_txt=users_txt[:-2] |
| 349 | | |
| 350 | | if mode == "exec": |
| 351 | | #activar arrastrar y soltar |
| 352 | | self.main.ask_fixed.show() |
| 353 | | self.main.ask_dragdrop.show() |
| 354 | | self.main.image_entry.show() |
| 355 | | self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| 356 | | self.main.ask_label.set_markup( _("<b>Exec app in user(s) screen(s):</b>\n%s" ) %( users_txt ) ) |
| 357 | | elif mode == "mess": |
| 358 | | self.main.ask_label.set_markup( _("<b>Send a message to:</b>\n%s" ) %( users_txt ) ) |
| 359 | | elif mode == "any": |
| 360 | | self.main.ask_label.set_markup( msg ) |
| 361 | | self.ask_mode=mode |
| 362 | | self.main.ask.show() |
| 363 | | return True |
| 364 | | |
| 365 | | def exe_app_in_client(self, mode, timeout=0, msg="", users=[], connected_users=[]): |
| 366 | | remote_cmd=("/usr/lib/tcos/session-cmd-send %s %s %s" %(mode.upper(), timeout, msg.replace("'", "´"))) |
| 367 | | action="down-controller %s %s" %(mode, timeout) |
| 368 | | print_debug("exe_app_in_client() usernames=%s" %users) |
| 369 | | |
| 370 | | if len(connected_users) != 0 and connected_users[0] != shared.NO_LOGIN_MSG: |
| 371 | | newusernames=[] |
| 372 | | for user in connected_users: |
| 373 | | if user.find(":") != -1: |
| 374 | | # we have a standalone user... |
| 375 | | usern, ip = user.split(":") |
| 376 | | self.main.xmlrpc.newhost(ip) |
| 377 | | self.main.xmlrpc.DBus("exec", remote_cmd ) |
| 378 | | else: |
| 379 | | newusernames.append(user) |
| 380 | | |
| 381 | | result = self.main.dbus_action.do_exec( newusernames ,remote_cmd ) |
| 382 | | |
| 383 | | if not result: |
| 384 | | shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) ) |
| 385 | | |
| 386 | | self.main.worker=shared.Workers(self.main, None, None) |
| 387 | | self.main.worker.set_for_all_action(self.action_for_clients,\ |
| 388 | | users, action ) |
| 389 | | return |
| 390 | | |
| 391 | | def exe_app_in_client_display(self, arg): |
| 392 | | usernames=self.ask_usernames |
| 393 | | newusernames=[] |
| 394 | | print_debug("exe_app_in_client_display() usernames=%s" %usernames) |
| 395 | | |