def __init__(self, color_1: str, color_2: str): super().__init__() self.model = Dazzle.GraphModel(value_min=0.0, value_max=100.0) self.model.add_column(Dazzle.GraphColumn(name="0", value_type=float)) self.model.add_column(Dazzle.GraphColumn(name="1", value_type=float)) self.add_renderer( Dazzle.GraphLineRenderer(column=0, stroke_color=color_1)) self.add_renderer( Dazzle.GraphLineRenderer(column=1, stroke_color=color_2)) self.set_model(self.model)
def create_install_popover(self): popover = Dazzle.SimplePopover(title=_('Install Rust Channel'), button_text=_('Install'), text='stable', ready=True, # translators: channel is stable, beta, nightly, with optional architecture and date message=_('Enter name of rust channel'), tooltip_text=_('''Standard release channel toolchain names have the following form: <channel>[-<date>][-<host>] <channel> = stable|beta|nightly|<version> <date> = YYYY-MM-DD <host> = <target-triple>''')) def add(popover, text): RustupApplicationAddin.instance.install_toolchain(text) popover.popdown() def changed(popover): popover.set_ready(looks_like_channel(popover.get_text())) popover.connect('activate', add) popover.connect('changed', changed) return popover
def present_results(self, results, name): headerbar = self.workbench.get_headerbar() search = Dazzle.gtk_widget_find_child_typed(headerbar, Ide.SearchEntry) search.set_text('') search.set_model(results) search.grab_focus() search.emit('show-suggestions')
def do_render(self, model: Dazzle.GraphModel, x_begin: int, x_end: int, y_begin: float, y_end: float, cairo_context: cairo.Context, area: cairo.RectangleInt) -> None: model_iter = Dazzle.GraphModelIter() cairo_context.save() if model.get_iter_first(model_iter): chunk = area.width / (model.props.max_samples - 1) / 2.0 last_x = self._calc_x(model_iter, x_begin, x_end, area.width) last_y = float(area.height) cairo_context.move_to(last_x, area.height) while Dazzle.GraphModel.iter_next(model_iter): x = self._calc_x(model_iter, x_begin, x_end, area.width) y = self._calc_y(model_iter, y_begin, y_end, area.height, self._column) cairo_context.curve_to(last_x + chunk, last_y, last_x + chunk, y, x, y) last_x = x last_y = y cairo_context.set_line_width(self._line_width) cairo_context.set_source_rgba(self._stacked_color_rgba.red, self._stacked_color_rgba.green, self._stacked_color_rgba.blue, self._stacked_color_rgba.alpha) cairo_context.rel_line_to(0, area.height) cairo_context.stroke_preserve() cairo_context.close_path() cairo_context.fill() if model.get_iter_first(model_iter): chunk = area.width / (model.props.max_samples - 1) / 2.0 last_x = self._calc_x(model_iter, x_begin, x_end, area.width) last_y = float(area.height) cairo_context.move_to(last_x, last_y) while Dazzle.GraphModel.iter_next(model_iter): x = self._calc_x(model_iter, x_begin, x_end, area.width) y = self._calc_y(model_iter, y_begin, y_end, area.height, self._column) cairo_context.curve_to(last_x + chunk, last_y, last_x + chunk, y, x, y) last_x = x last_y = y cairo_context.set_source_rgba(self._stroke_color_rgba.red, self._stroke_color_rgba.green, self._stroke_color_rgba.blue, self._stacked_color_rgba.alpha) cairo_context.stroke() cairo_context.restore()
def __init__(self, item, **kwargs): super().__init__(**kwargs) self.download_progress_icon_box.add( Dazzle.ProgressIcon(progress=item.download_progress, visible=True, expand=True)) for i, j in ((item.title, self.download_progress_actionrow.set_title), (item.subtitle, self.download_progress_actionrow.set_subtitle)): if i is not None: j(i)
def present_results(self, results, name): headerbar = self.workspace.get_header_bar() button = Dazzle.gtk_widget_find_child_typed(headerbar, Ide.SearchButton) button.grab_focus() search = button.get_entry() search.set_text('') search.set_model(results) search.grab_focus() search.emit('show-suggestions')
def _init_graphs(self) -> None: if is_dazzle_version_supported(): self._graph_views: Dict[GraphType, Tuple[Gtk.Label, Gtk.Label, Gtk.Label]] = {} self._graph_models: Dict[GraphType, Dazzle.GraphModel] = {} for graph_type in GraphType: self._graph_container: Gtk.Frame = self._builder.get_object(f'graph_container_{graph_type.value}') self._graph_views[graph_type] = (self._builder.get_object(f'graph_min_value_{graph_type.value}'), self._builder.get_object(f'graph_max_value_{graph_type.value}'), self._builder.get_object(f'graph_max_axis_{graph_type.value}')) graph_views = Dazzle.GraphView() graph_model = Dazzle.GraphModel() graph_renderer = GraphStackedRenderer() graph_views.set_hexpand(True) graph_views.props.height_request = 80 graph_renderer.set_line_width(1.5) stroke_color = Gdk.RGBA() stroke_color.parse(GRAPH_COLOR_HEX) stacked_color = Gdk.RGBA() stacked_color.parse(GRAPH_COLOR_HEX) stacked_color.alpha = 0.5 graph_renderer.set_stroke_color_rgba(stroke_color) graph_renderer.set_stacked_color_rgba(stacked_color) graph_model.set_timespan(MONITORING_INTERVAL * 1000 * 1000) graph_model.set_max_samples(MONITORING_INTERVAL / self._presenter.get_refresh_interval() + 1) graph_model.props.value_max = 100.0 graph_model.props.value_min = 0.0 column_ram = Dazzle.GraphColumn().new("Col0", TYPE_DOUBLE) graph_model.add_column(column_ram) graph_views.set_model(graph_model) graph_views.add_renderer(graph_renderer) self._graph_container.add(graph_views) graph_model_iter = graph_model.push(GLib.get_monotonic_time()) graph_model.iter_set(graph_model_iter, 0, 0.0) self._graph_models[graph_type] = graph_model
def do_load(self, workbench): print('Builder Workbench Addin: Load Bracer plugin workbench') editor = workbench.get_perspective_by_name('editor') dock_pane = Ide.EditorPerspective.get_utilities(editor) dock_widget = Dazzle.DockWidget( title=_('Rust Docs'), icon_name='accessories-dictionary-symbolic', visible=True, expand=False) Bracer.dock_widget = dock_widget if Bracer.settings.get_boolean('prefs-documentation'): if Bracer.settings.get_boolean('prefs-markdown'): Bracer._MARKDOWN_CSS = Bracer.get_data( 'resources/markdown.css') Bracer._HL_GITHUB_CSS = Bracer.get_data('resources/github.css') Bracer._MARKED_JS = Bracer.get_data('resources/marked.js') Bracer._HL_JS = Bracer.get_data('resources/hljs.js') Bracer._MARKDOWN_VIEW_JS = Bracer.get_data( 'resources/markdown-view.js') webview = WebKit2.WebView(visible=True, expand=True) Bracer.dock_webview = webview settings = webview.get_settings() settings.enable_html5_local_storage = False Bracer.dock_widget.add(Bracer.dock_webview) Ide.LayoutPane.add(dock_pane, Bracer.dock_widget) else: dock_text_widget = Gtk.TextView(visible=True, expand=True) Bracer.dock_text_widget = dock_text_widget scrolled = Gtk.ScrolledWindow(visible=True) scrolled.add(Bracer.dock_text_widget) Bracer.dock_widget.add(scrolled) Ide.LayoutPane.add(dock_pane, Bracer.dock_widget)
def refresh_graphs(self, data_dict: Dict[GraphType, Tuple[int, float, str, float, float]]) -> None: time1 = time.time() for graph_type, data_tuple in data_dict.items(): max_value = self._graph_models[graph_type].props.value_max self._graph_models[graph_type].props.value_max = max(data_tuple[4], max_value) graph_model_iter = self._graph_models[graph_type].push(GLib.get_monotonic_time()) self._graph_models[graph_type].iter_set(graph_model_iter, 0, data_tuple[1]) self._graph_views[graph_type][2].set_text(f"{data_tuple[1]:.0f} {data_tuple[2]}") model_iter = Dazzle.GraphModelIter() if self._dialog.props.visible and self._graph_models[graph_type].get_iter_first(model_iter): min_value = data_tuple[4] * 10 max_value = data_tuple[3] while Dazzle.GraphModel.iter_next(iter=model_iter): gval = GObject.Value() Dazzle.GraphModel.iter_get_value(iter=model_iter, column=0, value=gval) val = gval.get_double() min_value = min(val, min_value) max_value = max(val, max_value) self._graph_views[graph_type][0].set_text(f"{min_value:.0f}") self._graph_views[graph_type][1].set_text(f"{max_value:.0f}") self._graph_models[graph_type].props.value_max = max(data_tuple[4], max_value) time2 = time.time() LOG.debug(f'Refresh graph took {((time2 - time1) * 1000.0):.3f} ms')
def __init__(self, **kwargs): super().__init__(**kwargs) #uff=[{"title_repr":"Convert to wav","subtitle_repr":"wav","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"wav"}]}},{"title_repr":"Convert to mp3","subtitle_repr":"mp3","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"mp3"}]}},{"title_repr":"Convert to aac","subtitle_repr":"aac","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"aac"}]}},{"title_repr":"Convert to flac","subtitle_repr":"flac","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"flac"}]}},{"title_repr":"Convert to m4a","subtitle_repr":"m4a","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"m4a"}]}},{"title_repr":"Convert to opus","subtitle_repr":"opus","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"opus"}]}},{"title_repr":"Convert to vorbis","subtitle_repr":"vorbis","icon_name":"audio-x-generic-symbolic","ydl_opts":{'extractaudio':True,'postprocessors':[{'key': 'FFmpegExtractAudio', 'preferredcodec':"vorbis"}]}},{"title_repr":"Convert to mp4","subtitle_repr":"mp4","icon_name":"video-x-generic-symbolic","ydl_opts":{'postprocessors':[{'key': 'FFmpegVideoConvertor', 'format':"mp4"}]}},{"title_repr":"Convert to flv","subtitle_repr":"flv","icon_name":"video-x-generic-symbolic","ydl_opts":{'postprocessors':[{'key': 'FFmpegVideoConvertor', 'format':"flv"}]}},{"title_repr":"Convert to ogg","subtitle_repr":"ogg","icon_name":"video-x-generic-symbolic","ydl_opts":{'postprocessors':[{'key': 'FFmpegVideoConvertor', 'format':"ogg"}]}},{"title_repr":"Convert to avi","subtitle_repr":"avi","icon_name":"video-x-generic-symbolic","ydl_opts":{'postprocessors':[{'key': 'FFmpegVideoConvertor', 'format':"avi"}]}},{"title_repr":"Convert to mkv","subtitle_repr":"mkv","icon_name":"video-x-generic-symbolic","ydl_opts":{'postprocessors':[{'key': 'FFmpegVideoConvertor', 'format':"mkv"}]}},{"title_repr":"Convert to webm","subtitle_repr":"webm","icon_name":"video-x-generic-symbolic","ydl_opts":{'postprocessors':[{'key': 'FFmpegVideoConvertor', 'format':"webm"}]}}] #for u in uff: # ar=FormatsRow(u["icon_name"],u["title_repr"],u["subtitle_repr"],u["ydl_opts"]) # self.conversionlb.prepend(ar) for a in self.conversionlb.get_children(): if a.get_subtitle() in ['mp4', 'webm', 'mkv', 'avi', 'ogg', 'flv']: a.ydl_opts = { 'postprocessors': [{ 'key': 'FFmpegVideoConvertor', 'format': a.get_subtitle() }] } elif a.get_subtitle() in [ 'mp3', 'wav', 'vorbis', 'opus', 'm4a', 'flac', 'aac' ]: a.ydl_opts = { 'extractaudio': True, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': a.get_subtitle() }] } self.leaflet2.connect("notify::folded", self.on_leaflet_visible_changed) self.dnd_stack.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) self.dnd_stack.drag_dest_add_text_targets() self.set_property("lstore", Gio.ListStore.new(Item)) self.gtklb.bind_model(self.lstore, self.mflb) self.lstore.connect("items_changed", self.on_lstore_items_changed) self.empty_state = Dazzle.EmptyState( visible=True, icon_name=self.get_application().get_application_id() + "-symbolic", title=GLib.get_application_name(), subtitle= "• Click ➕ above to type in URL or to search,\n• click 📋 above to paste URL from Clipboard, or\n• Drag-and-Drop URL here." ) self.dnd_stack.add(self.empty_state) self.on_lstore_items_changed(None, None, None, None) self.set_property("downloadprogressliststore", Gio.ListStore.new(DownloadProgressItem)) self.refresh_bind_model() self.ficb.set_current_folder(DEFAULT_DOWNLOAD_FOLDER) self.authentification_expander_row.connect( "notify::enable-expansion", self.on_authentification_expander_row_enable_expansion_changed) self.custom_code_expander_row.connect( "notify::enable-expansion", self.on_custom_code_expander_row_enable_expansion_changed) self.geobypass_expander_row.connect( "notify::enable-expansion", self.on_geobypass_expander_row_enable_expansion_changed)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) GLib.timeout_add(500, self.update) # Chart # CPU self.cpu_circle = Chart( _("CPU"), "#f44336", "#9E9E9E" ) # Memory self.memory_circle = Chart( _("Memory"), "#E91E63", "#9E9E9E" ) # Swap self.swap_circle = Chart( _("Swap"), "#4CAF50", "#9E9E9E" ) # Speed # Disk self.disk_speed = SpeedBox( _("Disk"), _("Read Speed"), _("Write Speed"), "#9C27B0", "#FF9800" ) # Network self.network_speed = SpeedBox( _("Network"), _("Send Speed"), _("Recive Speed"), "#3F51B5", "#FF5722" ) # Finalize speed = Gtk.VBox(spacing=10) speed.set_homogeneous(True) speed.pack_start(self.disk_speed, True, True, 0) speed.pack_start(self.network_speed, True, True, 0) # Process List # CPU self.process_cpu = CPUProcess() # Memory self.process_memory = MemoryProcess() # Graph # Label cpu_label = Gtk.VBox(spacing=10) for number in range(util.get_cpu_count()): cpu_label.pack_start( HeaderLabel(CPU_COLOR[number], label=f"CPU{number}"), True, True, 0 ) memory_label = LabelBox( _("Memory"), _("Swap"), "#E91E63", "#4CAF50" ) disk_label = LabelBox( _("Read Speed"), _("Write Speed"), "#9C27B0", "#FF9800" ) network_label = LabelBox( _("Send Speed"), _("Recive Speed"), "#3F51B5", "#FF5722" ) # Memory self.memory_graph = Graph( "#E91E63", "#4CAF50" ) # Disk self.disk_graph = VariableGraph( "#9C27B0", "#FF9800" ) # Network self.network_graph = VariableGraph( "#3F51B5", "#FF5722" ) # Main Layout 1 # Layout 1 layout_1 = Gtk.HBox(spacing=10) layout_1.set_homogeneous(True) layout_1.pack_start(self.cpu_circle, True, True, 0) layout_1.pack_start(self.memory_circle, True, True, 0) layout_1.pack_start(self.swap_circle, True, True, 0) layout_1.pack_start(speed, True, True, 0) # Layout 2 layout_2 = Gtk.HBox(spacing=10) layout_2.set_homogeneous(True) layout_2.pack_start(self.process_cpu, True, True, 0) layout_2.pack_start(self.process_memory, True, True, 0) # Finalize main_layout_1 = Gtk.VBox(spacing=10) main_layout_1.set_homogeneous(True) main_layout_1.pack_start(layout_1, True, True, 0) main_layout_1.pack_start(layout_2, True, True, 0) # Main Layout 2 # Layout 1 layout_1 = Gtk.VBox(spacing=10) layout_1.set_homogeneous(True) layout_1.pack_start(cpu_label, True, True, 0) layout_1.pack_start(memory_label, True, True, 0) layout_1.pack_start(disk_label, True, True, 0) layout_1.pack_start(network_label, True, True, 0) # Layout 2 layout_2 = Gtk.VBox(spacing=10) layout_2.set_homogeneous(True) layout_2.pack_start(Dazzle.CpuGraph(), True, True, 0) layout_2.pack_start(self.memory_graph, True, True, 0) layout_2.pack_start(self.disk_graph, True, True, 0) layout_2.pack_start(self.network_graph, True, True, 0) # Finalize main_layout_2 = Gtk.HBox(spacing=10) main_layout_2.pack_start(layout_1, False, False, 0) main_layout_2.pack_start(layout_2, True, True, 0) # Stack self.stack = Gtk.Stack() self.stack.add_titled(main_layout_1, "circle", _("Overview")) self.stack.add_titled(main_layout_2, "graph", _("Graph")) stack_switcher = Gtk.StackSwitcher() stack_switcher.set_stack(self.stack) # Finalize self.header.add(stack_switcher) self.main.add(self.stack) self.update() self.show_all()