A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/themix-project/themix-gui/commit/e32af404b83e9b2b1f0cd72f76a623787d2de366 below:

add drop-down with "replace all instances" on color… · themix-project/themix-gui@e32af40 · GitHub

@@ -316,10 +316,67 @@ def __init__(self, transient_for, callback):

316 316

self.connect("clicked", self.on_click)

317 317 318 318 319 +

class OomoxLinkedDropdown(Gtk.MenuButton):

320 + 321 +

drop_down = None

322 + 323 +

def build_dropdown_menu(self):

324 +

self.drop_down = Gtk.Menu()

325 +

menu_items = []

326 +

menu_items.append([Gtk.MenuItem(label=_("Replace all instances")), self.replace_all_instances])

327 + 328 +

for item in menu_items:

329 +

self.drop_down.append(item[0])

330 +

item[0].connect("activate", item[1])

331 + 332 +

self.drop_down.show_all()

333 +

return self.drop_down

334 + 335 +

def replace_all_instances(self, _menu_item): # pylint:disable=unused-argument

336 + 337 +

color_selection_dialog = OomoxColorSelectionDialog(

338 +

self.transient_for, self.get_fuzzy_sibling(OomoxColorButton).gtk_color

339 +

)

340 +

color_selection_dialog.run()

341 +

new_color = color_selection_dialog.gtk_color

342 +

if new_color:

343 +

new_color.string = convert_gdk_to_theme_color(new_color)

344 +

old_color = self.get_fuzzy_sibling(OomoxColorButton).gtk_color

345 +

old_color.string = convert_gdk_to_theme_color(old_color)

346 + 347 +

cousins = self.get_fuzzy_ancestor(Gtk.ListBox).get_children()

348 +

for lbr in cousins:

349 +

if isinstance(lbr, ColorListBoxRow) and lbr.color_button.gtk_color is not None:

350 +

if convert_gdk_to_theme_color(lbr.color_button.gtk_color) == old_color.string:

351 +

lbr.set_value(new_color.string, connected=True)

352 + 353 +

def get_fuzzy_ancestor(self, desired_class):

354 +

potential_ancestor = self.get_parent()

355 +

while not isinstance(potential_ancestor, desired_class):

356 +

potential_ancestor = potential_ancestor.get_parent()

357 +

if isinstance(potential_ancestor, Gtk.Application):

358 +

break

359 +

else:

360 +

return potential_ancestor

361 + 362 +

def get_fuzzy_sibling(self, desired_class):

363 +

potential_siblings = self.get_parent().get_children()

364 +

for potential_sibling in potential_siblings:

365 +

if isinstance(potential_sibling, desired_class):

366 +

return potential_sibling

367 +

return None

368 + 369 +

def __init__(self, transient_for):

370 +

super().__init__()

371 +

self.transient_for = transient_for

372 +

self.set_popup(self.build_dropdown_menu())

373 + 374 + 319 375

class ColorListBoxRow(OomoxListBoxRow):

320 376 321 377

color_button = None

322 378

color_entry = None

379 +

menu_button = None

323 380 324 381

def connect_changed_signal(self):

325 382

self.changed_signal = self.color_entry.connect("changed", self.on_color_input)

@@ -340,16 +397,18 @@ def on_color_set(self, gtk_value):

340 397

self.value = convert_gdk_to_theme_color(gtk_value)

341 398

self.color_entry.set_text(self.value)

342 399 343 -

def set_value(self, value):

344 -

self.disconnect_changed_signal()

400 +

def set_value(self, value, connected=False): # pylint: disable=arguments-differ

401 +

if connected is False:

402 +

self.disconnect_changed_signal()

345 403

self.value = value

346 404

if value:

347 405

self.color_entry.set_text(self.value)

348 406

self.color_button.set_rgba(convert_theme_color_to_gdk(value))

349 407

else:

350 408

self.color_entry.set_text(_('<N/A>'))

351 409

self.color_button.set_rgba(convert_theme_color_to_gdk(FALLBACK_COLOR))

352 -

self.connect_changed_signal()

410 +

if connected is False:

411 +

self.connect_changed_signal()

353 412 354 413

def __init__(self, display_name, key, callback, transient_for):

355 414

self.color_button = OomoxColorButton(

@@ -359,13 +418,15 @@ def __init__(self, display_name, key, callback, transient_for):

359 418

self.color_entry = Gtk.Entry(

360 419

text=_('<none>'), width_chars=6, max_length=6

361 420

)

421 +

self.menu_button = OomoxLinkedDropdown(transient_for)

362 422

self.color_entry.get_style_context().add_class(Gtk.STYLE_CLASS_MONOSPACE)

363 423

linked_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

364 424

Gtk.StyleContext.add_class(

365 425

linked_box.get_style_context(), "linked"

366 426

)

367 427

linked_box.add(self.color_entry)

368 428

linked_box.add(self.color_button)

429 +

linked_box.add(self.menu_button)

369 430

super().__init__(

370 431

display_name=display_name,

371 432

key=key,


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4