Dealt with the GTK deprecation warnings

This commit is contained in:
Sumner Evans
2019-07-03 17:45:31 -06:00
parent 595085ff1d
commit e5073a88e4
4 changed files with 31 additions and 13 deletions

View File

@@ -108,7 +108,8 @@ class MainWindow(Gtk.ApplicationWindow):
menu_items = [
(None, self.connected_to_label),
('app.configure-servers', Gtk.ModelButton('Connect to Server')),
('app.configure-servers',
Gtk.ModelButton(label='Connect to Server')),
]
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

View File

@@ -214,7 +214,7 @@ class PlayerControls(Gtk.ActionBar):
# Scrubber and song progress/length labels
scrubber_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self.song_progress_label = Gtk.Label('-:--')
self.song_progress_label = Gtk.Label(label='-:--')
scrubber_box.pack_start(self.song_progress_label, False, False, 5)
self.song_scrubber = Gtk.Scale.new_with_range(
@@ -227,7 +227,7 @@ class PlayerControls(Gtk.ActionBar):
self.on_scrub_state_change)
scrubber_box.pack_start(self.song_scrubber, True, True, 0)
self.song_duration_label = Gtk.Label('-:--')
self.song_duration_label = Gtk.Label(label='-:--')
scrubber_box.pack_start(self.song_duration_label, False, False, 5)
box.add(scrubber_box)
@@ -290,13 +290,13 @@ class PlayerControls(Gtk.ActionBar):
popover_box_header = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self.popover_label = Gtk.Label(
'<b>Up Next</b>',
label='<b>Up Next</b>',
use_markup=True,
halign=Gtk.Align.START,
)
popover_box_header.add(self.popover_label)
load_up_next = Gtk.Button('Load Queue from Server', margin=5)
load_up_next = Gtk.Button(label='Load Queue from Server', margin=5)
load_up_next.set_action_name('app.update-play-queue-from-server')
popover_box_header.pack_end(load_up_next, False, False, 0)

View File

@@ -1,10 +1,9 @@
import gi
import re
from pathlib import Path
from typing import List, OrderedDict
from deepdiff import DeepDiff
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, Gtk, Pango, GObject, GLib, Gdk
@@ -65,7 +64,7 @@ class PlaylistsPanel(Gtk.Paned):
add_icon = Gio.ThemedIcon(name='list-add')
image = Gtk.Image.new_from_gicon(add_icon, Gtk.IconSize.LARGE_TOOLBAR)
box.add(image)
box.add(Gtk.Label('New Playlist', margin=5))
box.add(Gtk.Label(label='New Playlist', margin=5))
self.new_playlist.add(box)
self.new_playlist.connect('clicked', self.on_new_playlist_clicked)
playlist_list_actions.pack_start(self.new_playlist)
@@ -239,7 +238,9 @@ class PlaylistsPanel(Gtk.Paned):
self.playlist_songs.append_column(
create_column('DURATION', 4, align=1, width=40))
self.playlist_songs.connect('row-activated', self.on_song_double_click)
self.playlist_songs.connect('row-activated', self.on_song_activated)
self.playlist_songs.connect('button-press-event',
self.on_song_button_press)
# Set up drag-and-drop on the song list for editing the order of the
# playlist.
@@ -341,12 +342,19 @@ class PlaylistsPanel(Gtk.Paned):
self.playlist_list.get_selected_row().get_index()]
self.update_playlist_view(playlist.id, force=True)
def on_song_double_click(self, treeview, idx, column):
def on_song_activated(self, treeview, idx, column):
# The song ID is in the last column of the model.
song_id = self.playlist_song_model[idx][-1]
self.emit('song-clicked', song_id,
[m[-1] for m in self.playlist_song_model])
def on_song_button_press(self, tree, button):
if button.button == 3: # Right click
print('right click')
# TODO show the popup
# TODO should probably have a menu button on each of the songs in
# the list.
def on_playlist_list_new_entry_activate(self, entry):
self.create_playlist(entry.get_text())
@@ -357,9 +365,13 @@ class PlaylistsPanel(Gtk.Paned):
self.create_playlist(self.playlist_list_new_entry.get_text())
def playlist_model_row_move(self, *args):
# If we are programatically editing the song list, don't do anything.
if self.editing_playlist_song_list:
return
# We get both a delete and insert event, I think it's deterministic
# which one comes first, but just in case, we have this
# reordering_playlist_song_list flag..
if self.reordering_playlist_song_list:
selected = self.playlist_list.get_selected_row()
playlist = self.playlist_map[selected.get_index()]
@@ -371,7 +383,12 @@ class PlaylistsPanel(Gtk.Paned):
# Helper Methods
# =========================================================================
def make_label(self, text=None, name=None, **params):
return Gtk.Label(text, name=name, halign=Gtk.Align.START, **params)
return Gtk.Label(
label=text,
name=name,
halign=Gtk.Align.START,
**params,
)
def update(self, state: ApplicationState):
self.set_playlist_view_loading(False)

View File

@@ -87,7 +87,7 @@ class EditFormDialog(Gtk.Dialog):
# Create all of the text entry fields.
for label, value_field_name, is_password in self.text_fields:
# Put the label in the left box.
entry_label = Gtk.Label(label + ':')
entry_label = Gtk.Label(label=label + ':')
entry_label.set_halign(Gtk.Align.START)
label_box.pack_start(entry_label, True, True, 0)
@@ -102,7 +102,7 @@ class EditFormDialog(Gtk.Dialog):
# Create all of the check box fields.
for label, value_field_name in self.boolean_fields:
# Put the label in the left box.
entry_label = Gtk.Label(label + ':')
entry_label = Gtk.Label(label=label + ':')
entry_label.set_halign(Gtk.Align.START)
label_box.pack_start(entry_label, True, True, 0)