| 1 |
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas) |
| 2 |
# |
| 3 |
# This file is part of DeVeDe-NG |
| 4 |
# |
| 5 |
# DeVeDe-NG is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License version 3 |
| 7 |
# as published by the Free Software Foundation. |
| 8 |
# |
| 9 |
# DeVeDe-NG is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/> |
| 16 |
|
| 17 |
from gi.repository import Gtk, GObject |
| 18 |
import os |
| 19 |
|
| 20 |
|
| 21 |
class title(GObject.GObject): |
| 22 |
|
| 23 |
counter = 0 |
| 24 |
|
| 25 |
def __init__(self, config, file_treeview, original_liststore, title_name=None): |
| 26 |
|
| 27 |
GObject.GObject.__init__(self) |
| 28 |
self.config = config |
| 29 |
self.file_treeview = file_treeview |
| 30 |
if (title_name is None): |
| 31 |
title.counter += 1 |
| 32 |
self.title_name = _("Title %(X)d") % {"X": title.counter} |
| 33 |
else: |
| 34 |
self.title_name = title_name |
| 35 |
self.post_action = "stop" |
| 36 |
columns = [] |
| 37 |
for iterator in range(0, original_liststore.get_n_columns()): |
| 38 |
columns.append(original_liststore.get_column_type(iterator)) |
| 39 |
self.files = Gtk.ListStore() |
| 40 |
self.files.set_column_types(columns) |
| 41 |
|
| 42 |
def set_type(self, disc_type): |
| 43 |
|
| 44 |
self.disc_type = disc_type |
| 45 |
|
| 46 |
def properties(self): |
| 47 |
|
| 48 |
builder = Gtk.Builder() |
| 49 |
builder.set_translation_domain(self.config.gettext_domain) |
| 50 |
|
| 51 |
builder.add_from_file(os.path.join( |
| 52 |
self.config.glade, "wtitle_properties.ui")) |
| 53 |
builder.connect_signals(self) |
| 54 |
|
| 55 |
# Interface widgets |
| 56 |
wtitle_properties = builder.get_object("title_properties") |
| 57 |
wtitle = builder.get_object("entry_title") |
| 58 |
wplay_first = builder.get_object("play_first") |
| 59 |
wplay_prev = builder.get_object("play_previous") |
| 60 |
wplay_again = builder.get_object("play_again") |
| 61 |
wplay_next = builder.get_object("play_next") |
| 62 |
wplay_last = builder.get_object("play_last") |
| 63 |
|
| 64 |
wtitle.set_text(self.title_name) |
| 65 |
builder.get_object(self.post_action).set_active(True) |
| 66 |
|
| 67 |
wtitle_properties.show_all() |
| 68 |
retval = wtitle_properties.run() |
| 69 |
if (retval == 2): |
| 70 |
self.title_name = wtitle.get_text() |
| 71 |
if (wplay_first.get_active()): |
| 72 |
self.post_action = "play_first" |
| 73 |
elif (wplay_prev.get_active()): |
| 74 |
self.post_action = "play_previous" |
| 75 |
elif (wplay_again.get_active()): |
| 76 |
self.post_action = "play_again" |
| 77 |
elif (wplay_next.get_active()): |
| 78 |
self.post_action = "play_next" |
| 79 |
elif (wplay_last.get_active()): |
| 80 |
self.post_action = "play_last" |
| 81 |
else: |
| 82 |
self.post_action = "stop" |
| 83 |
|
| 84 |
wtitle_properties.destroy() |
| 85 |
|
| 86 |
def delete_title(self): |
| 87 |
|
| 88 |
print("Deleted title " + self.title_name) |
| 89 |
|
| 90 |
def refresh(self): |
| 91 |
|
| 92 |
self.file_treeview.set_model(self.files) |
| 93 |
|
| 94 |
def add_file(self, new_file): |
| 95 |
|
| 96 |
self.files.append([new_file.file_name, new_file]) |