def __init__(self): gtk.Box.__init__(self) dbuilder= gtk.Builder() dbuilder.add_from_file(get_ui_path('distrib.glade')) self.builder = dbuilder dbox = dbuilder.get_object("distbox") release = dbuilder.get_object("release_label") release.set_label("Galicaster "+__version__) recorder = dbuilder.get_object("button1") manager = dbuilder.get_object("button2") quit_button = dbuilder.get_object("button3") shutdown_button = dbuilder.get_object("button4") profile_button = dbuilder.get_object("profile_button") self.selected = dbuilder.get_object("selected_profile") self.update_selected_profile() #Connect signals dispatcher = context.get_dispatcher() dispatcher.connect("reload-profile", self.update_selected_profile) recorder.connect("clicked", self.emit_signal, "change_mode", 0) manager.connect("clicked", self.emit_signal, "change_mode", 1) quit_button.connect("clicked", self.emit_signal, "galicaster-quit") shutdown_button.connect("clicked", self.emit_signal, "galicaster-shutdown") profile_button.connect("clicked", self.on_profile_button) about = dbuilder.get_object("aboutevent") about.connect("button-press-event", self.show_about_dialog) conf = context.get_conf() quit_button.set_visible(conf.get_boolean("basic", "quit")) shutdown_button.set_visible(conf.get_boolean("basic", "shutdown")) self.pack_start(dbox, True, True, 0)
def __init__(self): ManagerUI.__init__(self, 3) self.menu = Gtk.Menu() self.fill_menu() builder = Gtk.Builder() builder.add_from_file(get_ui_path('listing.glade')) release = builder.get_object("release_label") release.set_label(get_footer()) self.gui = builder self.box = builder.get_object("listingbox") self.vista = builder.get_object("vista") self.scroll = builder.get_object("scrolledw") self.vista.get_selection().set_mode(Gtk.SelectionMode.SINGLE) # could SELECTION_MULTIPLE old_style = context.get_conf().get_color_style() self.color = context.get_conf().get_palette(old_style) builder.connect_signals(self) self.dispatcher.connect_ui("action-mm-refresh-row", self.refresh_row_from_mp) self.dispatcher.connect_ui("operation-started", self.refresh_operation) self.dispatcher.connect_ui("operation-stopped", self.refresh_operation) self.dispatcher.connect_ui("view-changed", self.event_change_mode) self.populate_treeview(list(self.repository.list().values())) self.box.pack_start(self.strip,False,False,0) self.box.reorder_child(self.strip,0) self.box.show() self.pack_start(self.box,True,True,0)
def set_style(self): """ Apply the main style of the application from the CSS """ style_provider = Gtk.CssProvider() style_provider.load_from_path(get_ui_path('style.css')) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
def __init__(self): ManagerUI.__init__(self, 3) self.menu = Gtk.Menu() self.fill_menu() builder = Gtk.Builder() builder.add_from_file(get_ui_path('listing.glade')) release = builder.get_object("release_label") release.set_label(get_footer()) self.gui = builder self.box = builder.get_object("listingbox") self.vista = builder.get_object("vista") self.scroll = builder.get_object("scrolledw") self.vista.get_selection().set_mode(Gtk.SelectionMode.SINGLE) # could SELECTION_MULTIPLE old_style = context.get_conf().get_color_style() self.color = context.get_conf().get_palette(old_style) builder.connect_signals(self) self.dispatcher.connect_ui("action-mm-refresh-row", self.refresh_row_from_mp) self.dispatcher.connect_ui("operation-started", self.refresh_operation) self.dispatcher.connect_ui("operation-stopped", self.refresh_operation) self.dispatcher.connect_ui("view-changed", self.event_change_mode) self.populate_treeview(self.repository.list().values()) self.box.pack_start(self.strip,False,False,0) self.box.reorder_child(self.strip,0) self.box.show() self.pack_start(self.box,True,True,0)
def __init__(self): ManagerUI.__init__(self, 3) builder = gtk.Builder() builder.add_from_file(get_ui_path('listing.glade')) self.gui = builder self.box = builder.get_object("listingbox") self.vista = builder.get_object("vista") self.scroll = builder.get_object("scrolledw") self.vista.get_selection().set_mode( gtk.SELECTION_SINGLE) # could SELECTION_MULTIPLE old_style = context.get_conf().get_color_style() self.color = context.get_conf().get_palette(old_style) builder.connect_signals(self) self.dispatcher.connect("refresh-row", self.refresh_row_from_mp) self.dispatcher.connect("start-operation", self.refresh_operation) self.dispatcher.connect("stop-operation", self.refresh_operation) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.populate_treeview(self.repository.list().values()) self.box.pack_start(self.strip, False, False, 0) self.box.reorder_child(self.strip, 0) self.box.show() self.pack_start(self.box, True, True, 0)
def __init__(self): ManagerUI.__init__(self, 3) builder = gtk.Builder() builder.add_from_file(get_ui_path('listing.glade')) self.gui = builder self.box = builder.get_object("listingbox") self.vista = builder.get_object("vista") self.scroll = builder.get_object("scrolledw") self.vista.get_selection().set_mode(gtk.SELECTION_SINGLE) # could SELECTION_MULTIPLE old_style = context.get_conf().get_color_style() self.color = context.get_conf().get_palette(old_style) builder.connect_signals(self) self.dispatcher.connect("refresh-row", self.refresh_row_from_mp) self.dispatcher.connect("start-operation", self.refresh_operation) self.dispatcher.connect("stop-operation", self.refresh_operation) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.populate_treeview(self.repository.list().values()) self.box.pack_start(self.strip,False,False,0) self.box.reorder_child(self.strip,0) self.box.show() self.pack_start(self.box,True,True,0)
def __init__(self, package=None, parent=None): self.gui = gtk.Builder() self.gui.add_from_file(get_ui_path('conf.glade')) self.conf = context.get_conf() dialog = self.gui.get_object("confdialog") if parent != None: dialog.set_transient_for(parent.get_toplevel()) self.shifter1 = self.gui.get_object('playershift') self.shifter2 = self.gui.get_object('recordshift') self.shifter1.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.shifter1.connect("button-press-event", self.on_toggle) # CHANGE method name self.shifter2.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.shifter2.connect("button-press-event", self.on_toggle) # CHANGE method name if self.conf.get("screen", "player") == "presentation": self.on_toggle(self.shifter1, None) if self.conf.get("screen", "recorder") == "presentation": self.on_toggle(self.shifter2, None) self.populate_conf() response = dialog.run() if response > 1: # FIXME, need a main print "Galicaster Configuration Update" self.update_conf() elif response == 1: print "Galicaster Configuration Update" # FIXME just apply changes dont close self.update_conf() else: print "Cancel Configuration" dialog.destroy()
def __init__(self,package = None, parent = None): self.gui = gtk.Builder() self.gui.add_from_file(get_ui_path('conf.glade')) self.conf=context.get_conf() dialog = self.gui.get_object("confdialog") if parent != None: dialog.set_transient_for(parent.get_toplevel()) self.shifter1 = self.gui.get_object('playershift') self.shifter2 = self.gui.get_object('recordshift') self.shifter1.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.shifter1.connect("button-press-event",self.on_toggle) # CHANGE method name self.shifter2.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.shifter2.connect("button-press-event",self.on_toggle) # CHANGE method name if self.conf.get("screen","player") == "presentation": self.on_toggle(self.shifter1, None) if self.conf.get("screen","recorder") == "presentation": self.on_toggle(self.shifter2, None) self.populate_conf() response = dialog.run() if response > 1: # FIXME, need a main print "Galicaster Configuration Update" self.update_conf() elif response == 1: print "Galicaster Configuration Update"# FIXME just apply changes dont close self.update_conf() else: print "Cancel Configuration" dialog.destroy()
def create_ui(self, buttons, text, icon, parent, modifier = None, another = False): """Imports the dialog from the corresponding GLADE and adds some configuration""" #dialog # TODO: Overwrite info text if given gui = Gtk.Builder() gui.add_from_file(get_ui_path(icon)) image = gui.get_object("image") image.set_pixel_size(int(self.wprop*80)) if icon != INFO: main = gui.get_object("main") main.set_label(text.get('main','')) else: help_message = "{}\n{}".format(text.get('main',''),text.get('text','')) textbuffer = gui.get_object('textbuffer') textbuffer.set_text(help_message) dialog = gui.get_object("dialog") text_label = gui.get_object('text') if text_label: text_label.set_label(text.get('text','')) dialog.set_type_hint(Gdk.WindowTypeHint.TOOLBAR) dialog.set_skip_taskbar_hint(True) dialog.set_keep_above(False) #HEADER strip = Header(size=self.size, title=text.get("title","Galicaster")) dialog.vbox.pack_start(strip, True, True, 0) dialog.vbox.reorder_child(strip,0) dialog.set_property('width-request',int(self.size[0]/2.5)) # relative to screen size if self.size[0]<1300: dialog.set_property('width-request',int(self.size[0]/2.2)) if another: dialog.set_property('width-request',int(self.size[0]/1.5)) if parent != None: dialog_style_context = dialog.get_style_context() window_classes = parent.get_style_context().list_classes() for style_class in window_classes: dialog_style_context.add_class(style_class) dialog.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) dialog.set_transient_for(parent) dialog.set_destroy_with_parent(True) else: dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS) dialog.show_all() return dialog
def __init__(self, vertical = False): gtk.Box.__init__(self) builder = gtk.Builder() self.mute = False self.vertical = vertical if vertical: guifile=get_ui_path('audiobarv.glade') else: guifile=get_ui_path('audiobar.glade') builder.add_from_file(guifile) self.bar = builder.get_object("audiobar") box = builder.get_object("vbox") if vertical: self.volume = gtk.VolumeButton() self.volume.set_value(0.5) box.pack_end(self.volume,False,True,0) builder.connect_signals(self) self.vumeter=builder.get_object("vumeter")
def __init__(self,package = None, parent = None): parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 gui = gtk.Builder() gui.add_from_file(get_ui_path('metadata.glade')) dialog = gui.get_object("metadatadialog") dialog.set_property("width-request",int(anchura/2.2)) dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLBAR) dialog.set_keep_above(True) #NEW HEADER strip = Header(size=size, title="Edit Metadata") dialog.vbox.pack_start(strip, True, True, 0) dialog.vbox.reorder_child(strip,0) if parent != None: dialog.set_transient_for(parent.get_toplevel()) table = gui.get_object('infobox') dialog.vbox.set_child_packing(table, True, True, int(self.hprop*25), gtk.PACK_END) title = gui.get_object('title') sl = gui.get_object('slabel') cl = gui.get_object('clabel') talign = gui.get_object('table_align') modification = "bold "+str(int(k2*25))+"px" title.modify_font(pango.FontDescription(modification)) title.hide() talign.set_padding(int(k2*40),int(k2*40),0,0) mod2 = str(int(k1*35))+"px" sl.modify_font(pango.FontDescription(mod2)) cl.modify_font(pango.FontDescription(mod2)) self.fill_metadata(table, package) talign.set_padding(int(self.hprop*25), int(self.hprop*10), int(self.hprop*25), int(self.hprop*25)) dialog.vbox.set_child_packing(dialog.action_area, True, True, int(self.hprop*25), gtk.PACK_END) dialog.show_all() dialog.present() return_value = dialog.run() if return_value == -8: self.update_metadata(table,package) dialog.destroy()
def load_ui(element): try: builder = context.get_mainwindow().nbox.get_nth_page(PAGES["REC"]).gui except Exception: logger.debug("The view not exist") return None notebook = builder.get_object("data_panel") builder = Gtk.Builder() label = Gtk.Label("Camera Control") builder.add_from_file(get_ui_path("camera_control.glade")) notebook2 = builder.get_object("notebook1") label2 = builder.get_object("label2") label3 = builder.get_object("label3") label1 = builder.get_object("label1") label4 = builder.get_object("label4") label_style(label) label_style(label2, True) label_style(label3, True) label_style(label1, True, 12) label_style(label4, True, 12) notebook.append_page(notebook2, label) builder.connect_signals(event_handler) zoom_levels = conf.get_int('cameracontrol', 'zoom_levels') max_speed_pan_tilt = conf.get('cameracontrol', 'max_speed_pan_tilt') speed_zoom = builder.get_object("adjustment1") speed_pan_tilt = builder.get_object("adjustment2") speed_zoom.set_upper(zoom_levels) speed_pan_tilt.set_upper(int(max_speed_pan_tilt, 16)) speed_pan_tilt.set_value(int(max_speed_pan_tilt, 16) / 2) speed_zoom.set_value(zoom_levels / 2) grid = builder.get_object("grid1") size = context.get_mainwindow().get_size() k1 = size[0] / 1920.0 for button in grid.get_children(): try: image = button.get_children() if type(image[0]) == Gtk.Image: image[0].set_pixel_size(k1 * 40) except: pass admin = conf.get_boolean('basic', 'admin') for widget in ["grid2", "grid3"]: for button in builder.get_object(widget): if admin and "save" in button.get_name(): button.show_all() image = button.get_children() if type(image[0]) == Gtk.Image: image[0].set_pixel_size(int(k1 * 40)) else: image[0].set_use_markup(True) image[0].modify_font(Pango.FontDescription(str(int(k1 * 20))))
def set_style(self): """ Apply the main style of the application from the CSS """ style_provider = Gtk.CssProvider() style_provider.load_from_path(get_ui_path('style.css')) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION )
def __init__(self, vertical=False): gtk.Box.__init__(self) builder = gtk.Builder() self.mute = False self.vertical = vertical if vertical: guifile = get_ui_path('audiobarv.glade') else: guifile = get_ui_path('audiobar.glade') builder.add_from_file(guifile) self.bar = builder.get_object("audiobar") box = builder.get_object("vbox") if vertical: self.volume = gtk.VolumeButton() self.volume.set_value(0.5) box.pack_end(self.volume, False, True, 0) builder.connect_signals(self) self.vumeter = builder.get_object("vumeter")
def __init__(self, package=None): ManagerUI.__init__(self, 1) builder = Gtk.Builder() builder.add_from_file(get_ui_path('player.glade')) release = builder.get_object("release_label") release.set_label(get_footer()) self.gui = builder # BUILD GUI self.playerui = builder.get_object("playerbox") self.main_area = builder.get_object("videobox") self.player = None # Seek Bar self.duration = 0 self.seeking = False self.jump = 0 # seek value self.jump_id = 0 # seek signal id self.seek_bar = self.gui.get_object("seekbar") self.seek_bar.add_events(Gdk.EventMask.SCROLL_MASK) self.seek_bar.connect("change-value", self.on_seek) # VUMETER self.vumeterL = builder.get_object("progressbarL") self.vumeterR = builder.get_object("progressbarR") self.label_channels_player = builder.get_object( "label_channels_player") self.rangeVum = 50 self.stereo = True # STATUSBAR self.statusbar = builder.get_object("statusbar") self.status = builder.get_object("status") self.timer = builder.get_object("timer") self.video = builder.get_object("video") self.presenter = builder.get_object("presenter") self.playerui.pack_start(self.strip, False, False, 0) self.playerui.reorder_child(self.strip, 0) self.pack_start(self.playerui, True, True, 0) self.status = INIT self.previous = None self.change_state(INIT) self.mediapackage = None # The Mediapackage being reproduced self.thread_id = None builder.connect_signals(self) self.dispatcher.connect_ui("player-vumeter", self.set_vumeter) self.dispatcher.connect("player-status", self.change_state_bypass) self.dispatcher.connect_ui('play-list', self.play_from_list) self.dispatcher.connect_ui("view-changed", self.event_change_mode) self.dispatcher.connect_ui("quit", self.close)
def __init__(self, package=None, parent=None): parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 gui = gtk.Builder() gui.add_from_file(get_ui_path('metadata.glade')) dialog = gui.get_object("metadatadialog") dialog.set_property("width-request", int(anchura / 2.2)) dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLBAR) dialog.set_keep_above(True) #NEW HEADER strip = Header(size=size, title="Edit Metadata") dialog.vbox.pack_start(strip, True, True, 0) dialog.vbox.reorder_child(strip, 0) if parent != None: dialog.set_transient_for(parent.get_toplevel()) table = gui.get_object('infobox') dialog.vbox.set_child_packing(table, True, True, int(self.hprop * 25), gtk.PACK_END) title = gui.get_object('title') sl = gui.get_object('slabel') cl = gui.get_object('clabel') talign = gui.get_object('table_align') modification = "bold " + str(int(k2 * 25)) + "px" title.modify_font(pango.FontDescription(modification)) title.hide() talign.set_padding(int(k2 * 40), int(k2 * 40), 0, 0) mod2 = str(int(k1 * 35)) + "px" sl.modify_font(pango.FontDescription(mod2)) cl.modify_font(pango.FontDescription(mod2)) self.fill_metadata(table, package) talign.set_padding(int(self.hprop * 25), int(self.hprop * 10), int(self.hprop * 25), int(self.hprop * 25)) dialog.vbox.set_child_packing(dialog.action_area, True, True, int(self.hprop * 25), gtk.PACK_END) dialog.show_all() return_value = dialog.run() if return_value == -8: self.update_metadata(table, package) dialog.destroy()
def __init__(self,package=None): ManagerUI.__init__(self,1) builder = Gtk.Builder() builder.add_from_file(get_ui_path('player.glade')) release = builder.get_object("release_label") release.set_label(get_footer()) self.gui=builder # BUILD GUI self.playerui = builder.get_object("playerbox") self.main_area = builder.get_object("videobox") self.player = None # Seek Bar self.duration = 0 self.seeking = False self.jump=0 # seek value self.jump_id=0 # seek signal id self.seek_bar=self.gui.get_object("seekbar") self.seek_bar.add_events(Gdk.EventMask.SCROLL_MASK) self.seek_bar.connect("change-value", self.on_seek) # VUMETER self.vumeterL = builder.get_object("progressbarL") self.vumeterR = builder.get_object("progressbarR") self.label_channels_player = builder.get_object("label_channels_player") self.rangeVum = 50 self.stereo = True # STATUSBAR self.statusbar = builder.get_object("statusbar") self.status=builder.get_object("status") self.timer=builder.get_object("timer") self.video=builder.get_object("video") self.presenter=builder.get_object("presenter") self.playerui.pack_start(self.strip,False,False,0) self.playerui.reorder_child(self.strip,0) self.pack_start(self.playerui,True,True,0) self.status=INIT self.previous=None self.change_state(INIT) self.mediapackage=None # The Mediapackage being reproduced self.thread_id=None builder.connect_signals(self) self.dispatcher.connect_ui("player-vumeter", self.set_vumeter) self.dispatcher.connect("player-status", self.change_state_bypass) self.dispatcher.connect_ui('play-list', self.play_from_list) self.dispatcher.connect_ui("view-changed", self.event_change_mode) self.dispatcher.connect_ui("quit", self.close)
def __init__(self): gtk.Box.__init__(self) builder = gtk.Builder() builder.add_from_file(get_ui_path('statusbar.glade')) self.bar = builder.get_object("statusbar") builder.connect_signals(self) self.status=builder.get_object("status") self.timer=builder.get_object("timer") self.video=builder.get_object("video") self.presenter=builder.get_object("presenter")
def __init__(self): gtk.Box.__init__(self) builder = gtk.Builder() builder.add_from_file(get_ui_path('statusbar.glade')) self.bar = builder.get_object("statusbar") builder.connect_signals(self) self.status = builder.get_object("status") self.timer = builder.get_object("timer") self.video = builder.get_object("video") self.presenter = builder.get_object("presenter")
def __init__(self, package=None): ManagerUI.__init__(self, 1) builder = gtk.Builder() builder.add_from_file(get_ui_path('player.glade')) self.gui = builder # BUILD GUI self.playerui = builder.get_object("playerbox") self.main_area = builder.get_object("videobox") self.player = None # Seek Bar self.duration = 0 self.seeking = False self.jump = 0 # seek value self.jump_id = 0 # seek signal id self.correct = False # To correct SCROLL_JUMP, after release it self.seek_bar = self.gui.get_object("seekbar") self.seek_bar.add_events(gtk.gdk.SCROLL_MASK) self.seek_bar.connect("change-value", self.on_seek) # VUMETER self.audiobar = AudioBarClass() self.volume_bar = self.audiobar.volume self.volume_bar.connect("value-changed", self.on_volume2) self.vubox = builder.get_object("vubox") self.vubox.add(self.audiobar.bar) # STATUSBAR self.statusbar = StatusBarClass() sbox = builder.get_object("statusbox") sbox.add(self.statusbar.bar) self.playerui.pack_start(self.strip, False, False, 0) self.playerui.reorder_child(self.strip, 0) self.pack_start(self.playerui, True, True, 0) self.status = GC_INIT self.previous = None self.change_state(GC_INIT) self.mediapackage = None # The Mediapackage being reproduced self.thread_id = None builder.connect_signals(self) self.dispatcher.connect("update-play-vumeter", self.audiobar.SetVumeter) self.dispatcher.connect("play-stopped", self.change_state_bypass, GC_READY) self.dispatcher.connect('play-list', self.play_from_list) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.dispatcher.connect("galicaster-notify-quit", self.close)
def __init__(self,package=None): ManagerUI.__init__(self,1) builder = gtk.Builder() builder.add_from_file(get_ui_path('player.glade')) self.gui=builder # BUILD GUI self.playerui = builder.get_object("playerbox") self.main_area = builder.get_object("videobox") self.player = None # Seek Bar self.duration = 0 self.seeking = False self.jump=0 # seek value self.jump_id=0 # seek signal id self.correct=False # To correct SCROLL_JUMP, after release it self.seek_bar=self.gui.get_object("seekbar") self.seek_bar.add_events(gtk.gdk.SCROLL_MASK) self.seek_bar.connect("change-value", self.on_seek) # VUMETER self.audiobar=AudioBarClass() self.volume_bar = self.audiobar.volume self.volume_bar.connect("value-changed", self.on_volume2) self.vubox = builder.get_object("vubox") self.vubox.add(self.audiobar.bar) # STATUSBAR self.statusbar= StatusBarClass() sbox = builder.get_object("statusbox") sbox.add(self.statusbar.bar) self.playerui.pack_start(self.strip,False,False,0) self.playerui.reorder_child(self.strip,0) self.pack_start(self.playerui,True,True,0) self.status=GC_INIT self.previous=None self.change_state(GC_INIT) self.mediapackage=None # The Mediapackage being reproduced self.thread_id=None builder.connect_signals(self) self.dispatcher.connect("update-play-vumeter", self.audiobar.SetVumeter) self.dispatcher.connect("play-stopped", self.change_state_bypass, GC_READY) self.dispatcher.connect('play-list', self.play_from_list) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.dispatcher.connect("galicaster-notify-quit", self.close)
def warning_audio(element=None): # TODO make it generic global no_audio global no_audio_dialog global focus_is_active no_audio = True if focus_is_active and no_audio_dialog == None: gui = gtk.Builder() gui.add_from_file(get_ui_path('warning.glade')) no_audio_dialog = gui.get_object('dialog') no_audio_dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) no_audio_dialog.set_transient_for(context.get_mainwindow().get_toplevel()) no_audio_dialog.show() return True
def init(): global recorder, dispatcher, logger, config, repo, oc_client, METADATA, ACL config = context.get_conf().get_section(CONFIG_SECTION) or {} dispatcher = context.get_dispatcher() repo = context.get_repository() logger = context.get_logger() recorder = context.get_recorder() oc_client = context.get_occlient() with open(get_ui_path("series_metadata_template.json"), "r") as metadataFile: METADATA = Template(metadataFile.read()) with open(get_ui_path("acl_template.json"), "r") as aclFile: ACL = Template(aclFile.read()) try: dispatcher.connect("init", init_user_ui) except Exception as e: logger.error(e) logger.info("Set user loaded.")
def warning_audio(element=None): # TODO make it generic global no_audio global no_audio_dialog global focus_is_active no_audio = True if focus_is_active and no_audio_dialog == None: gui = gtk.Builder() gui.add_from_file(get_ui_path('warning.glade')) no_audio_dialog = gui.get_object('dialog') no_audio_dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) no_audio_dialog.set_transient_for( context.get_mainwindow().get_toplevel()) no_audio_dialog.show() return True
def on_quit_clicked(self, button): """Stops the preview and close the player""" gui = gtk.Builder() gui.add_from_file(get_ui_path("quit.glade")) dialog = gui.get_object("dialog") response = dialog.run() if response == gtk.RESPONSE_OK: dialog.destroy() if self.status > 0: self.player.quit() self.change_state(GC_EXIT) self.emit("delete_event", gtk.gdk.Event(gtk.gdk.DELETE)) else: dialog.destroy() return True
def __init__(self,package = None, parent = None): parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 gui = gtk.Builder() gui.add_from_file(get_ui_path('metadata.glade')) dialog = gui.get_object("metadatadialog") dialog.set_property("width-request",int(anchura/2.2)) dialog.set_property("border-width",int(anchura/50.0)) if parent != None: dialog.set_transient_for(parent.get_toplevel()) table = gui.get_object('infobox') title = gui.get_object('title') sl = gui.get_object('slabel') cl = gui.get_object('clabel') talign = gui.get_object('table_align') modification = "bold "+str(int(k2*25))+"px" title.modify_font(pango.FontDescription(modification)) talign.set_padding(int(k2*40),int(k2*40),0,0) mod2 = str(int(k1*35))+"px" sl.modify_font(pango.FontDescription(mod2)) cl.modify_font(pango.FontDescription(mod2)) self.fill_metadata(table, package) # Close Metadata dialog and update if dialog.run() == -8: self.update_metadata(table,package) dialog.destroy()
def __init__(self, back_page ): """ Creates a top bar widget with the Galicaster Logo. If a back_page is provided - the tab number on the Core notebook wiget - it will show a back to the previous page button. """ Gtk.Box.__init__(self) builder = Gtk.Builder() builder.add_from_file(get_ui_path('strip.glade')) self.builder = builder self.strip = builder.get_object("stripbox") button = builder.get_object("previousbutton") button.connect("clicked", self.emit_signal, "change-mode", back_page) about = builder.get_object("aboutevent") about.connect("button-press-event", self.show_about_dialog) self.pack_start(self.strip,True,True,0)
def create_pause_dialog(self, parent): gui = Gtk.Builder() gui.add_from_file(get_ui_path("paused.glade")) dialog = gui.get_object("dialog") dialog.set_transient_for(parent) dialog.set_type_hint(Gdk.WindowTypeHint.TOOLBAR) dialog.set_modal(True) dialog.set_keep_above(False) dialog.set_skip_taskbar_hint(True) scale = context.get_mainwindow().get_size()[1] / 100.0 size = int(scale*self.pausedialog_size) dialog.set_default_size(size,size) button = gui.get_object("image") pause_svg = get_image_path('gc-pause.svg') pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(pause_svg, size, size) button.set_from_pixbuf(pixbuf) return dialog
def __init__(self, back_page): """ Creates a top bar widget with the Galicaster Logo. If a back_page is provided - the tab number on the Core notebook wiget - it will show a back to the previous page button. """ gtk.Box.__init__(self) builder = gtk.Builder() builder.add_from_file(get_ui_path('strip.glade')) self.builder = builder self.strip = builder.get_object("stripbox") button = builder.get_object("previousbutton") button.connect("clicked", self.emit_signal, "change-mode", back_page) about = builder.get_object("aboutevent") about.connect("button-press-event", self.show_about_dialog) self.pack_start(self.strip, True, True, 0)
def on_pause(self, button): """Pauses or resumes a recording""" if self.status == GC_PAUSED: logger.debug("Resuming Recording") self.change_state(GC_RECORDING) self.recorder.resume() elif self.status == GC_RECORDING: logger.debug("Pausing Recording") self.change_state(GC_PAUSED) self.recorder.pause() gui = gtk.Builder() gui.add_from_file(get_ui_path("paused.glade")) self.pause_dialog = self.create_pause_dialog(self.get_toplevel()) response = self.pause_dialog.run() if response == 1: self.on_pause(None) self.pause_dialog.destroy()
def create_pause_dialog(self, parent): gui = gtk.Builder() gui.add_from_file(get_ui_path("paused.glade")) dialog = gui.get_object("dialog") dialog.set_transient_for(parent) dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLBAR) dialog.set_keep_above(True) dialog.set_skip_taskbar_hint(True) size = context.get_mainwindow().get_size() k2 = size[1] / 1080.0 size = int(k2 * 150) dialog.set_default_size(size, size) button = gui.get_object("image") pixbuf = gtk.gdk.pixbuf_new_from_file(get_image_path("gc-pause.svg")) pixbuf = pixbuf.scale_simple(size, size, gtk.gdk.INTERP_BILINEAR) button.set_from_pixbuf(pixbuf) return dialog
def create_pause_dialog(self, parent): gui = gtk.Builder() gui.add_from_file(get_ui_path("paused.glade")) dialog = gui.get_object("dialog") dialog.set_transient_for(parent) dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLBAR) dialog.set_keep_above(True) dialog.set_skip_taskbar_hint(True) size = context.get_mainwindow().get_size() k2 = size[1] / 1080.0 size = int(k2 * 150) dialog.set_default_size(size, size) button = gui.get_object("image") pixbuf = gtk.gdk.pixbuf_new_from_file(get_image_path('gc-pause.svg')) pixbuf = pixbuf.scale_simple(size, size, gtk.gdk.INTERP_BILINEAR) button.set_from_pixbuf(pixbuf) return dialog
def __init__(self, initial_value=0, parent_window=None): # print "Running CalendarWindow" self.gi = Gtk.Builder() self.gi.add_from_file(get_ui_path("datetime.glade")) self.gi.connect_signals(self) self.w = self.gi.get_object("dialog1") if parent_window: parent_window.set_transient_for(self) self.w.connect("focus-out-event", self.do_hide_calendar) self.calendar = self.gi.get_object("calendar1") if not initial_value: year, month, day, hour, minute, second, dow, doy, isdst = time.localtime() else: year, month, day, hour, minute, second, dow, doy, isdst = initial_value.timetuple() self.calendar.select_month(month - 1, year) self.calendar.select_day(day) spinhour = self.gi.get_object("hours") spinhour.set_value(hour) spinminute = self.gi.get_object("minutes") spinminute.set_value(minute)
def on_pause(self,button): """Pauses or resumes a recording""" if self.status == GC_PAUSED: logger.debug("Resuming Recording") self.change_state(GC_RECORDING) self.record.resume() elif self.status == GC_RECORDING: logger.debug("Pausing Recording") self.change_state(GC_PAUSED) self.record.pause() gui = gtk.Builder() gui.add_from_file(get_ui_path("paused.glade")) dialog = gui.get_object("dialog") self.pause_dialog=dialog #image = gui.get_object("image") button = gui.get_object("button") dialog.set_transient_for(self.get_toplevel()) response = dialog.run() if response == 1: self.on_pause(None) dialog.destroy()
def on_pause(self, button): """Pauses or resumes a recording""" if self.status == GC_PAUSED: logger.debug("Resuming Recording") self.change_state(GC_RECORDING) self.record.resume() elif self.status == GC_RECORDING: logger.debug("Pausing Recording") self.change_state(GC_PAUSED) self.record.pause() gui = gtk.Builder() gui.add_from_file(get_ui_path("paused.glade")) dialog = gui.get_object("dialog") self.pause_dialog = dialog #image = gui.get_object("image") button = gui.get_object("button") dialog.set_transient_for(self.get_toplevel()) response = dialog.run() if response == 1: self.on_pause(None) dialog.destroy()
def __init__(self): Gtk.Box.__init__(self) dbuilder= Gtk.Builder() dbuilder.add_from_file(get_ui_path('distrib.glade')) self.builder = dbuilder self.gui = dbuilder dbox = dbuilder.get_object("distbox") release = dbuilder.get_object("release_label") release.set_label(get_footer()) recorder = dbuilder.get_object("button1") manager = dbuilder.get_object("button2") quit_button = dbuilder.get_object("button3") shutdown_button = dbuilder.get_object("button4") profile_button = dbuilder.get_object("profile_button") self.selected = dbuilder.get_object("selected_profile") self.update_selected_profile() strip = StripUI(None) strip.resize() strip.set_logo() dbox.pack_start(strip,False,False,0) dbox.reorder_child(strip,0) #Connect signals dispatcher = context.get_dispatcher() dispatcher.connect_ui("action-reload-profile", self.update_selected_profile) recorder.connect("clicked", self.emit_signal, "action-view-change", 0) manager.connect("clicked", self.emit_signal, "action-view-change", 1) quit_button.connect("clicked", self.emit_signal, "action-quit") shutdown_button.connect("clicked", self.emit_signal, "action-shutdown") profile_button.connect("clicked", self.on_profile_button) conf = context.get_conf() quit_button.set_visible(conf.get_boolean("basic", "quit")) shutdown_button.set_visible(conf.get_boolean("basic", "shutdown")) self.pack_start(dbox, True, True, 0)
def on_quit(self,button=None): """Close active preview or recoridng and destroys the UI""" gui = gtk.Builder() gui.add_from_file(get_ui_path("quit.glade")) dialog = gui.get_object("dialog") dialog.set_transient_for(self.get_toplevel()) response =dialog.run() if response == gtk.RESPONSE_OK: dialog.destroy() if self.status >= GC_PREVIEW: self.recorder.stop_preview() self.change_state(GC_EXIT) logger.info("Closing Clock and Scheduler") self.scheduler_thread_id = None self.clock_thread = None # threads closed self.emit("delete_event", gtk.gdk.Event(gtk.gdk.DELETE)) else: dialog.destroy() return True
def on_quit(self, button=None): """Close active preview or recoridng and destroys the UI""" gui = gtk.Builder() gui.add_from_file(get_ui_path("quit.glade")) dialog = gui.get_object("dialog") dialog.set_transient_for(self.get_toplevel()) response = dialog.run() if response == gtk.RESPONSE_OK: dialog.destroy() if self.status >= GC_PREVIEW: self.record.stop_preview() self.change_state(GC_EXIT) logger.info("Closing Clock and Scheduler") self.scheduler_thread_id = None self.clock_thread = None # threads closed self.emit("delete_event", gtk.gdk.Event(gtk.gdk.DELETE)) else: dialog.destroy() return True
def __init__(self, initial_value=0, parent_window=None): #print "Running CalendarWindow" self.gi = gtk.Builder() self.gi.add_from_file(get_ui_path('datetime.glade')) self.gi.connect_signals(self) self.w = self.gi.get_object("dialog1") if parent_window: parent_window.set_transient_for(self) self.w.connect("focus-out-event", self.do_hide_calendar) self.calendar = self.gi.get_object("calendar1") if not initial_value: year, month, day, hour, minute, second, dow, doy, isdst = time.localtime( ) else: year, month, day, hour, minute, second, dow, doy, isdst = initial_value.timetuple( ) self.calendar.select_month(month - 1, year) self.calendar.select_day(day) spinhour = self.gi.get_object("hours") spinhour.set_value(hour) spinminute = self.gi.get_object("minutes") spinminute.set_value(minute)
def __init__(self, package = None, series_list = None, parent = None, title=_("Edit Metadata"), subtitle=_("Edit Metadata"), ok_label = _("Save"), ko_label = _("Cancel"), empty_series_label = NO_SERIES): """ """ parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 self.series_list = series_list self.empty_series_label = empty_series_label gui = gtk.Builder() gui.add_from_file(get_ui_path('metadata.glade')) dialog = gui.get_object("metadatadialog") # Set up the dialog's label gui.get_object("title").set_text(subtitle) # Set up the button text gui.get_object("slabel").set_label(ok_label) gui.get_object("clabel").set_label(ko_label) dialog.set_property("width-request",int(anchura/2.2)) dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLBAR) dialog.set_modal(True) dialog.set_keep_above(False) #NEW HEADER strip = Header(size=size, title=title) dialog.vbox.pack_start(strip, True, True, 0) dialog.vbox.reorder_child(strip,0) if parent != None: dialog.set_transient_for(parent.get_toplevel()) table = gui.get_object('infobox') dialog.vbox.set_child_packing(table, True, True, int(self.hprop*25), gtk.PACK_END) title = gui.get_object('title') sl = gui.get_object('slabel') cl = gui.get_object('clabel') talign = gui.get_object('table_align') modification = "bold "+str(int(k2*25))+"px" title.modify_font(pango.FontDescription(modification)) title.hide() talign.set_padding(int(k2*40),int(k2*40),0,0) mod2 = str(int(k1*35))+"px" sl.modify_font(pango.FontDescription(mod2)) cl.modify_font(pango.FontDescription(mod2)) # Get "blocked" and "mandatory" parameters blocked = set() mandatory = set() try: for term in context.get_conf().get('metadata', 'blocked').split(): try: blocked.add(EQUIV[term]) except KeyError: blocked.add(term) except (KeyError, AttributeError): # 'blocked' was not defined in configuration pass try: for term in context.get_conf().get('metadata', 'mandatory').split(): try: mandatory.add(EQUIV[term]) except KeyError: mandatory.add(term) except (KeyError, AttributeError): # 'mandatory' was not defined in configuration pass self.mandatory = {} ok_button = gui.get_object("savebutton") self.fill_metadata(table, package, ok_button, blocked, mandatory) self.check_mandatory(None, ok_button, check_all = True) talign.set_padding(int(self.hprop*25), int(self.hprop*10), int(self.hprop*25), int(self.hprop*25)) dialog.vbox.set_child_packing(dialog.action_area, True, True, int(self.hprop*25), gtk.PACK_END) dialog.show_all() self.return_value = dialog.run() if self.return_value == -8: self.update_metadata(table,package) dialog.destroy()
def __init__(self, package=None): logger.info("Creating Recording Area") Gtk.Box.__init__(self) builder = Gtk.Builder() builder.add_from_file(get_ui_path('recorder.glade')) release = builder.get_object("release_label") release.set_label(get_footer()) # TEST self.repo = context.get_repository() self.dispatcher = context.get_dispatcher() self.worker = context.get_worker() self.conf = context.get_conf() self.recorder = context.get_recorder() self.recorder.set_create_drawing_areas_func(self.create_drawing_areas) self.start_recording = False self.font = None self.scheduled_recording = False self.focus_is_active = False self.net_activity = None self.error_dialog = None self.close_before_response_action = False # BUILD self.recorderui = builder.get_object("recorderbox") self.main_area = builder.get_object("videobox") self.vubox = builder.get_object("vubox") self.gui = builder # VUMETER self.rangeVum = 50 self.thresholdVum = self.conf.get_float('audio','min') self.mute = False self.stereo = True self.vumeterL = builder.get_object("progressbarL") self.vumeterR = builder.get_object("progressbarR") self.label_channels= builder.get_object("label_channels") self.low_audio = False self.lowaudio_threshold = self.conf.get_float('lowaudio','lowaudio_threshold') # SWAP if not self.conf.get_boolean('basic', 'swapvideos'): self.gui.get_object("swapbutton").destroy() self.swap = False # STATUS self.view = self.set_status_view() hbox1 = self.gui.get_object('hbox1') hbox1.add(self.view) self.dispatcher.connect_ui("init", self.check_status_area) self.dispatcher.connect_ui("init", self.check_net, None) self.dispatcher.connect_ui("opencast-status", self.check_net) self.dispatcher.connect_ui("operation-started", self.check_operations) self.dispatcher.connect_ui("operation-stopped", self.check_operations) # UI self.pack_start(self.recorderui,True,True,0) self.pause_dialog = None # Event Manager self.dispatcher.connect_ui("recorder-vumeter", self.set_vumeter) self.dispatcher.connect_ui("view-changed", self.event_change_mode) self.dispatcher.connect_ui("recorder-status", self.handle_status) self.dispatcher.connect_ui("recorder-ready", self.reset_mute) # STATES self.previous = None # PERMISSIONS self.allow_pause = self.conf.get_permission("pause") self.allow_start = self.conf.get_permission("start") self.allow_stop = self.conf.get_permission("stop") self.allow_manual = self.conf.get_permission("manual") self.allow_overlap = self.conf.get_permission("overlap") self.help_main_str = self.conf.get('help', 'main') self.help_text_str = self.conf.get('help', 'text') # OTHER builder.connect_signals(self) self.net_activity = self.conf.get_boolean('ingest', 'active') self.pausedialog_size = self.conf.get_int('basic', 'pausedialog_size', default=15) if self.pausedialog_size < 5: self.pausedialog_size = 5 elif self.pausedialog_size > 100: self.pausedialog_size = 100 self.proportion = 1 #TIMEOUTS deps = self.update_scheduler_deps() GObject.timeout_add(500, self.update_scheduler_timeout, *deps) self.update_clock_timeout(self.gui.get_object("local_clock")) GObject.timeout_add(10000, self.update_clock_timeout, self.gui.get_object("local_clock"))
def __init__(self, message=None, text=TEXT, parent=None, buttons=None, response_action=None, close_on_response=True, show=[], close_parent = False, close_before_response_action = False): """ Initializes the Gtk.Dialog from its GLADE Args: message (str): type of message (See above constants) text (Dict{str:str}): Labels of the texts that are going to be set. parent (Gtk.Window): main window buttons (Dict{str:str}): button labels to be shown and its responses Notes: title key is asociated with the label of the GALICASTER strip. Any other key must be the same as the label id in the Glade. """ # FIXME: Workaround in order to avoid the garbage collector (GC) global instance instance = self #TODO: Remove unused params. # Parse Size proportions #FIXME: Use always as parent context.get_mainwindow()?? size = parent.get_size() self.response_action = response_action self.close_on_response = close_on_response self.close_before_response_action = close_before_response_action self.message = message self.close_parent = close_parent self.size = size self.wprop = size[0]/1920.0 self.hprop = size[1]/1080.0 self.dispatcher = context.get_dispatcher() # Create dialog self.gui = Gtk.Builder() self.gui.add_from_file(get_ui_path(message)) self.gui.connect_signals(self) self.dialog = self.configure_ui(text, message, self.gui, parent) # Specific glade modifications if message == OPERATIONS: frames = {'Cancel': {'Cancel' : -2}} for operation, response in buttons.iteritems(): if operation.count('Ingest'): if not frames.has_key('Ingest'): frames['Ingest'] = {} frames['Ingest'][operation] = response elif operation.count('Side') or operation.count('Export'): if not frames.has_key('Export'): frames['Export'] = {} frames['Export'][operation] = response self.set_buttons(self.gui, frames) elif message == MP_INFO: if text.has_key('tracks'): grid = self.gui.get_object('tracks_grid') if grid: self.fill_info(grid, text['tracks']) if text.has_key('catalogs'): grid = self.gui.get_object('catalogs_grid') if grid: self.fill_info(grid, text['catalogs']) elif message == ABOUT: self.set_logos(self.gui) # WORKAROUND (TTK-16472): # In some graphical environments the GtkAboutDialog default buttons would not appear # This blocks Galicaster, as the dialog can't be closed # As a workaround, we add a "Close" button if the dialog buttonbox is empty # A more permanent solution might be crafting the about window manually about_buttonbox = self.gui.get_object("aboutdialog-action_area1") if len(about_buttonbox.get_children()) == 0 : about_buttonbox.get_parent().set_property('visible' ,True) close_button = Gtk.Button().new_with_label(_("Close")) close_button.set_property('visible' ,True) close_button.connect("clicked", self.dialog_destroy) about_buttonbox.pack_start(close_button, False, True, 0) elif message == NEXT_REC: if text['next_recs']: self.fill_mp_info(self.gui, text['next_recs']) else: no_recs = self.gui.get_object('no_recordings') if no_recs: no_recs.show() elif message == LOCKSCREEN: for element in show: gtk_obj = self.gui.get_object(element) if gtk_obj: gtk_obj.show() self.gui.get_object("quitbutton").connect("clicked", context.get_mainwindow().do_quit) # Display dialog parent.get_style_context().add_class('shaded') self.dialog.set_transient_for(parent) if message in [ERROR, WARN_QUIT, WARN_STOP, ABOUT, INFO, WARN_DELETE, LOCKSCREEN, MP_INFO]: self.dispatcher.emit("action-audio-disable-msg") self.dialog.show() self.dialog.connect('response', self.on_dialog_response) #elif message == ABOUT: # #TODO: use on_dialog_response instead of on_about_dialog_response # self.dialog.show_all() # self.dialog.connect('response', self.on_about_dialog_response) else: self.response = self.dialog.run() self.dialog.destroy() parent.get_style_context().remove_class('shaded')
def __init__(self, package=None): logger.info("Creating Recording Area") Gtk.Box.__init__(self) builder = Gtk.Builder() builder.add_from_file(get_ui_path('recorder.glade')) release = builder.get_object("release_label") release.set_label(get_footer()) # TEST self.repo = context.get_repository() self.dispatcher = context.get_dispatcher() self.worker = context.get_worker() self.conf = context.get_conf() self.recorder = context.get_recorder() self.recorder.set_create_drawing_areas_func(self.create_drawing_areas) self.start_recording = False self.font = None self.scheduled_recording = False self.focus_is_active = False self.net_activity = None self.error_dialog = None self.close_before_response_action = False # BUILD self.recorderui = builder.get_object("recorderbox") self.main_area = builder.get_object("videobox") self.vubox = builder.get_object("vubox") self.gui = builder # VUMETER self.rangeVum = 50 self.thresholdVum = self.conf.get_float('audio', 'min') self.mute = False self.stereo = True self.vumeterL = builder.get_object("progressbarL") self.vumeterR = builder.get_object("progressbarR") self.label_channels = builder.get_object("label_channels") # SWAP if not self.conf.get_boolean('basic', 'swapvideos'): self.gui.get_object("swapbutton").destroy() self.swap = False # STATUS self.view = self.set_status_view() hbox1 = self.gui.get_object('hbox1') hbox1.add(self.view) self.dispatcher.connect_ui("init", self.check_status_area) self.dispatcher.connect_ui("init", self.check_net, None) self.dispatcher.connect_ui("opencast-status", self.check_net) # UI self.pack_start(self.recorderui, True, True, 0) self.pause_dialog = None # Event Manager self.dispatcher.connect_ui("recorder-vumeter", self.set_vumeter) self.dispatcher.connect_ui("view-changed", self.event_change_mode) self.dispatcher.connect_ui("recorder-status", self.handle_status) self.dispatcher.connect_ui("recorder-ready", self.reset_mute) # STATES self.previous = None # PERMISSIONS self.allow_pause = self.conf.get_permission("pause") self.allow_start = self.conf.get_permission("start") self.allow_stop = self.conf.get_permission("stop") self.allow_manual = self.conf.get_permission("manual") self.allow_overlap = self.conf.get_permission("overlap") self.help_main_str = self.conf.get('help', 'main') self.help_text_str = self.conf.get('help', 'text') # OTHER builder.connect_signals(self) self.net_activity = self.conf.get_boolean('ingest', 'active') self.proportion = 1 #TIMEOUTS deps = self.update_scheduler_deps() GObject.timeout_add(500, self.update_scheduler_timeout, *deps) self.update_clock_timeout(self.gui.get_object("local_clock")) GObject.timeout_add(10000, self.update_clock_timeout, self.gui.get_object("local_clock"))
def __init__(self, package=None): logger.info("Creating Recording Area") gtk.Box.__init__(self) builder = gtk.Builder() builder.add_from_file(get_ui_path('recorder.glade')) self.repo = context.get_repository() self.dispatcher = context.get_dispatcher() self.worker = context.get_worker() self.recorder = None self.current_mediapackage = None self.current = None self.next = None self.restarting = False self.font = None self.scheduled_recording = False self.focus_is_active = False self.net_activity = None self.error_id = None self.error_text = None self.error_dialog = None self.ok_to_show = False self.swap_active = None self.swap = False # BUILD self.recorderui = builder.get_object("recorderbox") self.main_area = builder.get_object("videobox") self.vubox = builder.get_object("vubox") self.gui = builder # BIG STATUS big_status = builder.get_object("bg_status") self.view = self.set_status_view() big_status.add(self.view) # STATUS BAR self.statusbar=status_bar.StatusBarClass() self.dispatcher.connect("update-rec-status", self.statusbar.SetStatus) self.dispatcher.connect("update-video", self.statusbar.SetVideo) self.dispatcher.connect("galicaster-init", self.check_status_area) self.dispatcher.connect("galicaster-init", self.check_net) self.dispatcher.connect("restart-preview", self.check_status_area) self.dispatcher.connect("net-up", self.check_net, True) self.dispatcher.connect("net-down", self.check_net, False) self.statusbar.SetTimer(0) # VUMETER self.audiobar=Vumeter() # UI self.vubox.add(self.audiobar) self.pack_start(self.recorderui,True,True,0) # Event Manager self.dispatcher.connect("start-record", self.on_scheduled_start) self.dispatcher.connect("stop-record", self.on_stop) self.dispatcher.connect("start-before", self.on_start_before) self.dispatcher.connect("restart-preview", self.on_restart_preview) self.dispatcher.connect("update-rec-vumeter", self.audiobar.SetVumeter) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.dispatcher.connect("galicaster-notify-quit", self.close) nb=builder.get_object("data_panel") pages = nb.get_n_pages() for index in range(pages): page=nb.get_nth_page(index) nb.set_tab_label_packing(page, True, True,gtk.PACK_START) # STATES self.status = GC_INIT self.previous = None self.change_state(GC_INIT) self.dispatcher.connect("reload-profile", self.on_recover_from_error) # PERMISSIONS self.conf = context.get_conf() self.allow_pause = self.conf.get_permission("pause") self.allow_start = self.conf.get_permission("start") self.allow_stop = self.conf.get_permission("stop") self.allow_manual = self.conf.get_permission("manual") self.allow_overlap = self.conf.get_permission("overlap") # OTHER builder.connect_signals(self) self.net_activity = self.conf.get_boolean('ingest', 'active') self.change_state(GC_READY) self.proportion = 1 self.on_start() # SCHEDULER FEEDBACK self.scheduler_thread_id = 1 self.clock_thread_id = 1 self.start_thread_id = None self.scheduler_thread = thread(target=self.scheduler_launch_thread) self.clock_thread = thread(target=self.clock_launch_thread) self.scheduler_thread.daemon = True self.clock_thread.daemon = True self.scheduler_thread.start() self.clock_thread.start() self.dispatcher.emit("galicaster-init") # SHOW OR HIDE SWAP BUTTON if self.conf.get_boolean('basic', 'swapvideos'): self.swap_active = True else: self.swap_active = False
def __init__(self, message=None, text=TEXT, parent=None, buttons=None, response_action=None, close_on_response=True, show=[], close_parent=False, close_before_response_action=False): """ Initializes the Gtk.Dialog from its GLADE Args: message (str): type of message (See above constants) text (Dict{str:str}): Labels of the texts that are going to be set. parent (Gtk.Window): main window buttons (Dict{str:str}): button labels to be shown and its responses Notes: title key is asociated with the label of the GALICASTER strip. Any other key must be the same as the label id in the Glade. """ # FIXME: Workaround in order to avoid the garbage collector (GC) global instance instance = self #TODO: Remove unused params. # Parse Size proportions #FIXME: Use always as parent context.get_mainwindow()?? size = parent.get_size() self.response_action = response_action self.close_on_response = close_on_response self.close_before_response_action = close_before_response_action self.message = message self.close_parent = close_parent self.size = size self.wprop = size[0] / 1920.0 self.hprop = size[1] / 1080.0 self.dispatcher = context.get_dispatcher() # Create dialog self.gui = Gtk.Builder() self.gui.add_from_file(get_ui_path(message)) self.gui.connect_signals(self) self.dialog = self.configure_ui(text, message, self.gui, parent) # Specific glade modifications if message == OPERATIONS: frames = {'Cancel': {'Cancel': -2}} for operation, response in buttons.iteritems(): if operation.count('Ingest'): if not frames.has_key('Ingest'): frames['Ingest'] = {} frames['Ingest'][operation] = response elif operation.count('Side') or operation.count('Export'): if not frames.has_key('Export'): frames['Export'] = {} frames['Export'][operation] = response self.set_buttons(self.gui, frames) elif message == MP_INFO: if text.has_key('tracks'): grid = self.gui.get_object('tracks_grid') if grid: self.fill_info(grid, text['tracks']) if text.has_key('catalogs'): grid = self.gui.get_object('catalogs_grid') if grid: self.fill_info(grid, text['catalogs']) elif message == ABOUT: self.set_logos(self.gui) # WORKAROUND (TTK-16472): # In some graphical environments the GtkAboutDialog default buttons would not appear # This blocks Galicaster, as the dialog can't be closed # As a workaround, we add a "Close" button if the dialog buttonbox is empty # A more permanent solution might be crafting the about window manually about_buttonbox = self.gui.get_object("aboutdialog-action_area1") if len(about_buttonbox.get_children()) == 0: about_buttonbox.get_parent().set_property('visible', True) close_button = Gtk.Button().new_with_label(_("Close")) close_button.set_property('visible', True) close_button.connect("clicked", self.dialog_destroy) about_buttonbox.pack_start(close_button, False, True, 0) elif message == NEXT_REC: if text['next_recs']: self.fill_mp_info(self.gui, text['next_recs']) else: no_recs = self.gui.get_object('no_recordings') if no_recs: no_recs.show() elif message == LOCKSCREEN: for element in show: gtk_obj = self.gui.get_object(element) if gtk_obj: gtk_obj.show() self.gui.get_object("quitbutton").connect( "clicked", context.get_mainwindow().do_quit) # Display dialog parent.get_style_context().add_class('shaded') self.dialog.set_transient_for(parent) if message in [ ERROR, WARN_QUIT, WARN_STOP, ABOUT, INFO, WARN_DELETE, LOCKSCREEN, MP_INFO ]: self.dispatcher.emit("action-audio-disable-msg") self.dialog.show() self.dialog.connect('response', self.on_dialog_response) #elif message == ABOUT: # #TODO: use on_dialog_response instead of on_about_dialog_response # self.dialog.show_all() # self.dialog.connect('response', self.on_about_dialog_response) else: self.response = self.dialog.run() self.dialog.destroy() parent.get_style_context().remove_class('shaded')
def init_onvif_ui(element): global recorder_ui, builder # init function classes onvif = onvif_interface() dispatcher.connect("recorder-starting", onvif.on_start_recording) dispatcher.connect("recorder-stopped", onvif.on_stop_recording) recorder_ui = context.get_mainwindow().nbox.get_nth_page(0).gui # load css file css = Gtk.CssProvider() css.load_from_path(get_ui_path("camctrl.css")) Gtk.StyleContext.reset_widgets(Gdk.Screen.get_default()) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) # load glade file builder = Gtk.Builder() builder.add_from_file(get_ui_path("camctrl-onvif.glade")) # scaling of images/labels which do not get called at all # scale images imgs = ["ctrl", "zoom", "dummy", "settings"] for i in imgs: get_stock_icon(i) # scale label labels = ["control", "settings"] for i in labels: get_label(i) # add new settings tab to the notebook notebook = recorder_ui.get_object("data_panel") mainbox = builder.get_object("mainbox") notebook.append_page(mainbox, get_label("notebook")) # object lists movement = [ "left", "leftup", "leftdown", "right", "rightup", "rightdown", "up", "down", "fly_mode" ] zoom = ["zoom_in", "zoom_out"] scales = ["move", "zoom"] others = ["reset", "show_pref", "home"] # object initialisation # presets # note: preset objects have to be initialized individually # preset list presetlist = builder.get_object("preset_list") # add home position to list presetlist.insert(0, "home", "home") # fill the list with current presets for preset in cam.get_presets(): presetlist.append(preset.Name, preset.Name) # preset buttons # to set a new preset newpreset = builder.get_object("newpreset") entry = builder.get_object("entry") # to delete a preset presetdelbutton = builder.get_object("presetdel") presetdelbutton.add(get_stock_icon("presetdel")) # load non-modifiable presets nomodstring = config.get(NOMOD_PRESETS_KEY) if nomodstring is not None: nomodpresets = [x.strip() for x in nomodstring.split(',') if x != ''] else: nomodpresets = None # connect preset functions presetlist.connect("changed", onvif.change_preset, newpreset, presetdelbutton, nomodpresets) newpreset.connect("activate", onvif.save_preset, presetlist, nomodpresets) newpreset.connect("icon-press", onvif.save_preset_icon, presetlist, nomodpresets) newpreset.connect("focus-out-event", onvif.focus_out) entry.connect("inserted-text", onvif.check_entry_ins, newpreset, presetlist, nomodpresets) entry.connect("deleted-text", onvif.check_entry_del, newpreset, presetlist, nomodpresets) presetdelbutton.connect("clicked", onvif.empty_entry, presetlist) # scales and movement/zoom buttons for i in scales: scale = builder.get_object(i + "scale") scalelabel = get_label(i) scalelabel.set_text("{0:.1f}".format(scale.get_value())) scale.connect("value-changed", onvif.set_scale, scalelabel) if i == "move": # movement buttons for i in movement: button = builder.get_object(i) if i == "fly_mode": button.add(get_stock_icon(i)) button.connect("clicked", str_to_module("onvif_interface", i), scale, presetlist) else: button.add(get_icon(i)) button.connect( "pressed", str_to_module("onvif_interface", "move_" + i), scale, presetlist) button.connect("released", onvif.stop_move) button.connect("released", onvif.stop_move) elif i == "zoom": # zoom buttons for i in zoom: button = builder.get_object(i) button.add(get_stock_icon(i)) button.connect("pressed", str_to_module("onvif_interface", i), scale, presetlist) button.connect("released", onvif.stop_move) # other buttons for i in others: button = builder.get_object(i) if i == "home": button.add(get_icon(i)) button.connect("clicked", str_to_module("onvif_interface", "move_" + i), presetlist) elif i == "show_pref": button.connect("clicked", str_to_module("onvif_interface", i)) else: button.add(get_stock_icon(i)) button.connect("clicked", str_to_module("onvif_interface", i))
def __init__(self, number = None,): if number == None: number = HOW_MANY parent = context.get_mainwindow() size = parent.get_size() altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 gui = gtk.Builder() gui.add_from_file(get_ui_path('next.glade')) dialog = gui.get_object("dialog") table = gui.get_object("infobox") title = gui.get_object("titlelabel") okl = gui.get_object("oklabel") okb = gui.get_object("okbutton") modification = "bold "+str(int(k2*30))+"px" title.modify_font(pango.FontDescription(modification)) okl.modify_font(pango.FontDescription(modification)) # mediapackages mps=context.get_repository().get_next_mediapackages() row=1 self.dialog=dialog if parent != None: dialog.set_transient_for(parent.get_toplevel()) for mp in mps: t = self.big_label(mp.title, int(k1*30)) t.set_width_chars(int(k1*50)) t.set_line_wrap(True) # allocation = t.get_allocation() t.set_size_request( int(k1* 400) , -1 ) # FIXEME #Hack by http://tadeboro.blogspot.com/2009/05/wrapping-adn-resizing-gtklabel.html rec_time = mp.getLocalDate() if rec_time.date() == datetime.date.today(): upcoming = "Today" elif rec_time.date() == ( datetime.date.today()+datetime.timedelta(1) ): upcoming = "Tomorrow" else: upcoming = mp.getDate().strftime("%d %b %Y") # day_number month_abr year full d = self.big_label(upcoming,int(k1*30)) d.set_width_chars(20) h = self.big_label(rec_time.time().strftime("%H:%M"),int(k1*30)) h.set_width_chars(12) #l = self.big_label("Record Now", int(k1*30)) b = gtk.Button("Record Now") l = b.get_child() tamanho = pango.FontDescription(str(int(k1*25))+"px") l.modify_font(tamanho) b.set_alignment(0.5,0.5) b.set_property("tooltip-text","Record Now") b.connect("button-press-event",self.send_start, mp.identifier) b.set_property("width-request", int (k1*180)) b.set_property("height-request", int (k2*70)) table.attach(t,0,1,row-1,row,gtk.EXPAND|gtk.FILL,False,0,0) table.attach(d,1,2,row-1,row,gtk.EXPAND|gtk.FILL,False,0,0) table.attach(h,2,3,row-1,row,gtk.EXPAND|gtk.FILL,False,0,0) table.attach(b,3,4,row-1,row,gtk.EXPAND|gtk.FILL,False,0,0) t.show() h.show() d.show() b.show() row += 1 if row >= number+1 : break okb.connect("button-press-event",self.destroy) dialog.run() return None
def __init__( self, package=None, series_list=None, parent=None, title=_("Edit Metadata"), subtitle=_("Edit Metadata"), ok_label=_("Save"), ko_label=_("Cancel"), empty_series_label=NO_SERIES, ): """ """ parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 self.series_list = series_list self.empty_series_label = empty_series_label gui = Gtk.Builder() gui.add_from_file(get_ui_path("metadata.glade")) dialog = gui.get_object("metadatadialog") # Set up the dialog's label gui.get_object("title").set_text(subtitle) # Set up the button text gui.get_object("slabel").set_label(ok_label) gui.get_object("clabel").set_label(ko_label) dialog.set_property("width-request", int(anchura / 2.2)) dialog.set_type_hint(Gdk.WindowTypeHint.TOOLBAR) dialog.set_modal(True) dialog.set_keep_above(False) # NEW HEADER strip = Header(size=size, title=title) dialog.vbox.pack_start(strip, True, True, 0) dialog.vbox.reorder_child(strip, 0) if parent != None: dialog.set_transient_for(parent.get_toplevel()) dialog_style_context = dialog.get_style_context() window_classes = parent.get_style_context().list_classes() for style_class in window_classes: dialog_style_context.add_class(style_class) table = gui.get_object("infobox") dialog.vbox.set_child_packing(table, True, True, int(self.hprop * 25), Gtk.PackType.END) title = gui.get_object("title") sl = gui.get_object("slabel") cl = gui.get_object("clabel") talign = gui.get_object("table_align") title.hide() # Get "blocked" and "mandatory" parameters blocked = set() mandatory = set() try: for term in context.get_conf().get("metadata", "blocked").split(): try: blocked.add(EQUIV[term]) except KeyError: blocked.add(term) except (KeyError, AttributeError): # 'blocked' was not defined in configuration pass try: for term in context.get_conf().get("metadata", "mandatory").split(): try: mandatory.add(EQUIV[term]) except KeyError: mandatory.add(term) except (KeyError, AttributeError): # 'mandatory' was not defined in configuration pass self.mandatory = {} ok_button = gui.get_object("savebutton") self.fill_metadata(table, package, ok_button, blocked, mandatory) self.check_mandatory(None, ok_button, check_all=True) talign.set_padding(int(self.hprop * 25), int(self.hprop * 10), int(self.hprop * 25), int(self.hprop * 25)) dialog.vbox.set_child_packing(dialog.action_area, True, True, int(self.hprop * 25), Gtk.PackType.END) dialog.show_all() self.return_value = dialog.run() if self.return_value == -8: self.update_metadata(table, package) dialog.destroy()
def __init__(self, package=None): logger.info("Creating Recording Area") Gtk.Box.__init__(self) builder = Gtk.Builder() builder.add_from_file(get_ui_path('recorder.glade')) # TEST recorderui = builder.get_object("recorderbox") self.repo = context.get_repository() self.dispatcher = context.get_dispatcher() self.worker = context.get_worker() self.conf = context.get_conf() self.recorder = context.get_recorder() self.recorder.set_create_drawing_areas_func(self.create_drawing_areas) self.start_recording = False self.font = None self.scheduled_recording = False self.focus_is_active = False self.net_activity = None self.error_dialog = None # BUILD self.recorderui = builder.get_object("recorderbox") self.main_area = builder.get_object("videobox") self.vubox = builder.get_object("vubox") self.gui = builder # SWAP if not self.conf.get_boolean('basic', 'swapvideos'): self.gui.get_object("swapbutton").hide() self.swap = False # STATUS big_status = builder.get_object("bg_status") self.view = self.set_status_view() big_status.add(self.view) self.dispatcher.connect("galicaster-init", self.check_status_area) self.dispatcher.connect("galicaster-init", self.check_net) self.dispatcher.connect("net-up", self.check_net, True) self.dispatcher.connect("net-down", self.check_net, False) # VUMETER self.audiobar=Vumeter() # UI self.vubox.add(self.audiobar) self.pack_start(self.recorderui,True,True,0) # Event Manager self.dispatcher.connect("recorder-vumeter", self.audiobar.SetVumeter) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.dispatcher.connect("recorder-status", self.handle_status) nb=builder.get_object("data_panel") pages = nb.get_n_pages() for index in range(pages): page=nb.get_nth_page(index) # nb.set_tab_label_packing(page, True, True,Gtk.PackType.START) # STATES self.previous = None # PERMISSIONS self.allow_pause = self.conf.get_permission("pause") self.allow_start = self.conf.get_permission("start") self.allow_stop = self.conf.get_permission("stop") self.allow_manual = self.conf.get_permission("manual") self.allow_overlap = self.conf.get_permission("overlap") # OTHER builder.connect_signals(self) self.net_activity = self.conf.get_boolean('ingest', 'active') self.proportion = 1 #TIMEOUTS deps = self.update_scheduler_deps() GObject.timeout_add(500, self.update_scheduler_timeout, *deps) self.update_clock_timeout(self.gui.get_object("local_clock")) GObject.timeout_add(10000, self.update_clock_timeout, self.gui.get_object("local_clock"))
def __init__(self, _logger=None, title="Get My Info", client=None): """ """ self.id = "" self.user_name = "" self.user_email = "" self.series_id = "" self.series_title = "" self.searching = False self.details = None self.__logger = _logger self.__oc_client = client self.series_filter = config.get(CONFIG_SERIES_FILTER, DEFAULT_SERIES_FILTER) regexp = config.get(CONFIG_REGEXP, DEFAULT_REGEXP) self.__logger.info("REGEXP = " + regexp) self.__regexp = re.compile(regexp) parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 gui = Gtk.Builder() gui.add_from_file(get_ui_path('set_user.glade')) self.dialog = gui.get_object("setuserdialog") self.dialog.set_property("width-request", int(anchura / 2.2)) self.dialog.set_type_hint(Gdk.WindowTypeHint.TOOLBAR) self.dialog.set_modal(True) self.dialog.set_keep_above(False) # user select button self.user_button = Gtk.Button() #NEW HEADER strip = Header(size=size, title=title) self.dialog.vbox.pack_start(strip, True, True, 0) self.dialog.vbox.reorder_child(strip, 0) self.search_field = gui.get_object("inp_search") #search_field.connect('key-press-event', self.on_key_press) self.search_field.connect('key-release-event', self.on_key_release) #self.search_field.connect('search-changed', self.search_changed) #self.search_field.connect('stop-search', self.search_stopped) self.result = gui.get_object("grd_result") if parent != None: # FIXME: The keyboard plugin uses Ubuntu Onboard. # https://bugs.launchpad.net/onboard/+bug/1627819 # There is a bug with this plugin where the "dock to edges" # option does not work with the "force to top" one, causing # Onboard to appear behind when Galicaster is on fullscreen. # THIS affects #321. A better solution should be implemented. from galicaster import plugins if not parent.is_fullscreen or 'galicaster.plugins.keyboard' not in plugins.loaded: self.dialog.set_transient_for(parent.get_toplevel()) self.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS) dialog_style_context = self.dialog.get_style_context() window_classes = parent.get_style_context().list_classes() for style_class in window_classes: dialog_style_context.add_class(style_class) self.dialog.show_all() parent.get_style_context().add_class('shaded') self.return_value = self.dialog.run() parent.get_style_context().remove_class('shaded') self.dialog.destroy()
def __init__(self, package=None, parent=None, title=_("Edit Metadata"), subtitle=_("Edit Metadata"), ok_label=_("Save"), ko_label=_("Cancel"), empty_series_label=NO_SERIES): """ """ parent = context.get_mainwindow() size = parent.get_size() self.par = parent altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 self.wprop = k1 self.hprop = k2 ocservice = context.get_ocservice() self.series_list = [] if ocservice: self.series_list = context.get_ocservice().series self.empty_series_label = empty_series_label gui = Gtk.Builder() gui.add_from_file(get_ui_path('metadata.glade')) dialog = gui.get_object("metadatadialog") # Set up the dialog's label gui.get_object("title").set_text(subtitle) # Set up the button text gui.get_object("slabel").set_label(ok_label) gui.get_object("clabel").set_label(ko_label) dialog.set_property("width-request", int(anchura / 2.2)) #dialog.set_type_hint(Gdk.WindowTypeHint.TOOLBAR) #dialog.set_modal(True) #dialog.set_keep_above(False) #NEW HEADER strip = Header(size=size, title=title) dialog.vbox.pack_start(strip, True, True, 0) dialog.vbox.reorder_child(strip, 0) if parent != None: # FIXME: The keyboard plugin uses Ubuntu Onboard. # https://bugs.launchpad.net/onboard/+bug/1627819 # There is a bug with this plugin where the "dock to edges" # option does not work with the "force to top" one, causing # Onboard to appear behind when Galicaster is on fullscreen. # THIS affects #321. A better solution should be implemented. from galicaster import plugins if not parent.is_fullscreen or 'galicaster.plugins.keyboard' not in plugins.loaded: dialog.set_transient_for(parent.get_toplevel()) dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS) dialog_style_context = dialog.get_style_context() window_classes = parent.get_style_context().list_classes() for style_class in window_classes: dialog_style_context.add_class(style_class) table = gui.get_object('infobox') dialog.vbox.set_child_packing(table, True, True, int(self.hprop * 25), Gtk.PackType.END) title = gui.get_object('title') talign = gui.get_object('table_align') title.hide() # Get "blocked" and "mandatory" parameters blocked = set() mandatory = set() try: for term in context.get_conf().get('metadata', 'blocked').split(): try: blocked.add(EQUIV[term]) except KeyError: blocked.add(term) except (KeyError, AttributeError): # 'blocked' was not defined in configuration pass try: for term in context.get_conf().get('metadata', 'mandatory').split(): try: mandatory.add(EQUIV[term]) except KeyError: mandatory.add(term) except (KeyError, AttributeError): # 'mandatory' was not defined in configuration pass self.mandatory = {} ok_button = gui.get_object("savebutton") self.fill_metadata(table, package, ok_button, blocked, mandatory) self.check_mandatory(None, ok_button, check_all=True) talign.set_padding(int(self.hprop * 25), int(self.hprop * 10), int(self.hprop * 25), int(self.hprop * 25)) dialog.vbox.set_child_packing(dialog.action_area, True, True, int(self.hprop * 25), Gtk.PackType.END) dialog.show_all() parent.get_style_context().add_class('shaded') self.return_value = dialog.run() if self.return_value == -8: self.update_metadata(table, package) parent.get_style_context().remove_class('shaded') dialog.destroy()
def __init__(self, package=None): logger.info("Creating Recording Area") gtk.Box.__init__(self) builder = gtk.Builder() builder.add_from_file(get_ui_path('recorder.glade')) self.repo = context.get_repository() self.dispatcher = context.get_dispatcher() self.worker = context.get_worker() self.record = None self.current_mediapackage = None self.current = None self.next = None self.restarting = False self.font = None self.scheduled_recording = False self.focus_is_active = False self.net_activity = None self.error_id = None self.error_text = None self.error_dialog = None self.start_id = None # BUILD self.recorderui = builder.get_object("recorderbox") self.main_area = builder.get_object("videobox") self.areas = None self.vubox = builder.get_object("vubox") self.gui = builder # BIG STATUS big_status = builder.get_object("bg_status") self.view = self.set_status_view() big_status.add(self.view) # STATUS BAR self.statusbar = status_bar.StatusBarClass() self.dispatcher.connect("update-rec-status", self.statusbar.SetStatus) self.dispatcher.connect("update-video", self.statusbar.SetVideo) self.dispatcher.connect("galicaster-init", self.check_status_area) self.dispatcher.connect("galicaster-init", self.check_net) self.dispatcher.connect("restart-preview", self.check_status_area) self.dispatcher.connect("net-up", self.check_net, True) self.dispatcher.connect("net-down", self.check_net, False) self.statusbar.SetTimer(0) # VUMETER self.audiobar = AudioBarClass() # UI self.vubox.add(self.audiobar.bar) self.pack_start(self.recorderui, True, True, 0) # Event Manager self.dispatcher.connect("start-record", self.on_scheduled_start) self.dispatcher.connect("stop-record", self.on_scheduled_stop) self.dispatcher.connect("start-before", self.on_start_before) self.dispatcher.connect("restart-preview", self.on_restart_preview) self.dispatcher.connect("update-rec-vumeter", self.audiobar.SetVumeter) self.dispatcher.connect("galicaster-status", self.event_change_mode) self.dispatcher.connect("galicaster-notify-quit", self.close) nb = builder.get_object("data_panel") pages = nb.get_n_pages() for index in range(pages): page = nb.get_nth_page(index) nb.set_tab_label_packing(page, True, True, gtk.PACK_START) # STATES self.status = GC_INIT self.previous = None self.change_state(GC_INIT) self.dispatcher.connect("reload_profile", self.on_recover_from_error) # PERMISSIONS self.conf = context.get_conf() self.allow_pause = self.conf.get_permission("pause") self.allow_start = self.conf.get_permission("start") self.allow_stop = self.conf.get_permission("stop") self.allow_manual = self.conf.get_permission("manual") self.allow_overlap = self.conf.get_permission("overlap") # OTHER builder.connect_signals(self) self.net_activity = self.conf.get_boolean('ingest', 'active') self.change_state(GC_READY) self.proportion = 1 self.on_start() # SCHEDULER FEEDBACK self.scheduler_thread_id = 1 self.clock_thread_id = 1 self.start_thread_id = None self.scheduler_thread = thread(target=self.scheduler_launch_thread) self.clock_thread = thread(target=self.clock_launch_thread) self.scheduler_thread.daemon = True self.clock_thread.daemon = True self.scheduler_thread.start() self.clock_thread.start() self.dispatcher.emit("galicaster-init")
def __init__( self, number=None, ): if number == None: number = HOW_MANY parent = context.get_mainwindow() size = parent.get_size() altura = size[1] anchura = size[0] k1 = anchura / 1920.0 k2 = altura / 1080.0 gui = gtk.Builder() gui.add_from_file(get_ui_path('next.glade')) dialog = gui.get_object("dialog") table = gui.get_object("infobox") title = gui.get_object("titlelabel") okl = gui.get_object("oklabel") okb = gui.get_object("okbutton") modification = "bold " + str(int(k2 * 30)) + "px" title.modify_font(pango.FontDescription(modification)) okl.modify_font(pango.FontDescription(modification)) # mediapackages mps = context.get_repository().get_next_mediapackages() row = 1 self.dialog = dialog if parent != None: dialog.set_transient_for(parent.get_toplevel()) for mp in mps: t = self.big_label(mp.title, int(k1 * 30)) t.set_width_chars(int(k1 * 50)) t.set_line_wrap(True) # allocation = t.get_allocation() t.set_size_request(int(k1 * 400), -1) # FIXEME #Hack by http://tadeboro.blogspot.com/2009/05/wrapping-adn-resizing-gtklabel.html rec_time = mp.getLocalDate() if rec_time.date() == datetime.date.today(): upcoming = "Today" elif rec_time.date() == (datetime.date.today() + datetime.timedelta(1)): upcoming = "Tomorrow" else: upcoming = mp.getDate().strftime("%d %b %Y") # day_number month_abr year full d = self.big_label(upcoming, int(k1 * 30)) d.set_width_chars(20) h = self.big_label(rec_time.time().strftime("%H:%M"), int(k1 * 30)) h.set_width_chars(12) #l = self.big_label("Record Now", int(k1*30)) b = gtk.Button("Record Now") l = b.get_child() tamanho = pango.FontDescription(str(int(k1 * 25)) + "px") l.modify_font(tamanho) b.set_alignment(0.5, 0.5) b.set_property("tooltip-text", "Record Now") b.connect("button-press-event", self.send_start, mp.identifier) b.set_property("width-request", int(k1 * 180)) b.set_property("height-request", int(k2 * 70)) table.attach(t, 0, 1, row - 1, row, gtk.EXPAND | gtk.FILL, False, 0, 0) table.attach(d, 1, 2, row - 1, row, gtk.EXPAND | gtk.FILL, False, 0, 0) table.attach(h, 2, 3, row - 1, row, gtk.EXPAND | gtk.FILL, False, 0, 0) table.attach(b, 3, 4, row - 1, row, gtk.EXPAND | gtk.FILL, False, 0, 0) t.show() h.show() d.show() b.show() row += 1 if row >= number + 1: break okb.connect("button-press-event", self.destroy) dialog.run() return None