Commit 6d1b166f authored by Sergio Costas's avatar Sergio Costas

Added support for page blocks in menues

Now allows to add separators in the menu that forces a page jump,
allowing to group videos in pages.
parent c222c4ab
......@@ -40,6 +40,8 @@
<column type="gchararray"/>
<!-- column-name in_menu -->
<column type="gboolean"/>
<!-- column-name meaning -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkWindow" id="wmain_window">
......@@ -269,9 +271,18 @@
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeview5">
<child>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
<attribute name="text">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="title" translatable="yes">In menu</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderertext4">
<signal name="toggled" handler="on_cellrenderertext4_toggled" swapped="no"/>
......
......@@ -321,8 +321,8 @@ class dvd_menu(devedeng.interface_manager.interface_manager):
self.title_list = []
counter = 0
for element in self.file_list:
if element.show_in_menu:
if element.element_type == "file_movie":
if element.show_in_menu:
self.title_list.append((element, counter))
counter += 1
else:
......@@ -381,21 +381,28 @@ class dvd_menu(devedeng.interface_manager.interface_manager):
if (self.play_all_c):
entries_per_page -= 1
n_entries = len(self.title_list)
if (n_entries > entries_per_page):
self.pages = 1
n_entries = 0
self.page_list = [0]
entry = 0
for element in self.file_list:
if ((element.element_type == "separator") and element.page_jump) or (n_entries > entries_per_page):
self.pages += 1
n_entries = 1
self.page_list.append(entry)
entry += 1
if (page_number > self.pages) and (page_number > 0):
page_number = self.pages - 1
if (self.pages > 1):
paint_arrows = True
entries_per_page -= 1
else:
paint_arrows = False
self.pages = int(n_entries / entries_per_page)
if (n_entries == 0) or ((n_entries % entries_per_page) != 0):
self.pages += 1
if (page_number >= self.pages) and (page_number > 0):
page_number -= 1
if self.wcurrent_page is not None:
self.wcurrent_page.set_text(_("Page %(X)d of %(Y)d") % {
"X": page_number + 1, "Y": self.pages})
self.wcurrent_page.set_text(_("Page {0} of {1}").format(page_number + 1, self.pages))
xl = left_margin_p
xr = 720.0 - right_margin_p
y = top_margin_p + entry_height / 2.0
......@@ -419,7 +426,13 @@ class dvd_menu(devedeng.interface_manager.interface_manager):
xl, xr, y, self.position_horizontal)
y += entry_height
for entry in self.title_list[page_number * entries_per_page:(page_number + 1) * entries_per_page]:
for entry_position in range(entries_per_page):
entry_number = self.page_list[page_number] + entry_position
if entry_number >= len(self.title_list):
break
entry = self.title_list[entry_number]
if (entry_position != 0) and (entry[0].element_type == "separator") and (entry[0].page_jump):
break
if entry[0].element_type == "file_movie":
text = entry[0].title_name
is_movie = True
......
......@@ -203,6 +203,7 @@ class devede_project:
else:
if element.element_type != "file_movie":
self.wpreview_file.set_sensitive(False)
self.wproperties_file.set_sensitive(False)
nfiles = len(self.wfiles.get_model())
if (nfiles < 1):
self.wdelete_file.set_sensitive(False)
......@@ -217,7 +218,10 @@ class devede_project:
def on_cellrenderertext4_toggled(self, widget, path):
element = self.wliststore_files[path][0]
if element.element_type == "file_movie":
element.set_show_in_menu(False if widget.get_active() else True)
else:
element.set_page_jump(False if widget.get_active() else True)
def on_use_pal_toggled(self, b):
self.config.PAL = self.wuse_pal.get_active()
......@@ -279,7 +283,7 @@ class devede_project:
new_file.connect('title_changed', self.title_changed)
new_file.connect('in_menu_changed', self.in_menu_changed)
self.wliststore_files.append([new_file, new_file.title_name, True, self.duration_to_string(
new_file.get_duration()), new_file.show_in_menu])
new_file.get_duration()), new_file.show_in_menu, _("In menu")])
if (len(error_list) != 0):
devedeng.message.message_window(_("The following files could not be added:"), _(
"Error while adding files"), error_list)
......@@ -727,13 +731,13 @@ class devede_project:
new_file.connect('title_changed', self.title_changed)
new_file.connect('in_menu_changed', self.in_menu_changed)
self.wliststore_files.append([new_file, new_file.title_name, True, self.duration_to_string(
new_file.get_duration()), new_file.show_in_menu])
new_file.get_duration()), new_file.show_in_menu, _("In menu")])
else:
new_separator = devedeng.separator.separator()
new_separator.restore_element(element)
new_separator.connect('name_changed', self.title_changed)
new_separator.connect('in_menu_changed', self.in_menu_changed)
self.wliststore_files.append([new_separator, new_separator.separator_name, True, "", True])
new_separator.connect('page_jump_changed', self.in_menu_changed)
self.wliststore_files.append([new_separator, new_separator.separator_name, True, "", new_separator.page_jump, _("Page jump")])
if (len(error_list) != 0):
devedeng.message.message_window(_("The following files in the project could not be added again:"), _("Error while adding files"), error_list)
self.set_interface_status(None)
......@@ -754,7 +758,7 @@ class devede_project:
def on_add_separator_clicked(self, b):
new_separator = devedeng.separator.separator()
new_separator.connect('name_changed', self.title_changed)
new_separator.connect('in_menu_changed', self.in_menu_changed)
self.wliststore_files.append([new_separator, new_separator.separator_name, True, "", True])
new_separator.connect('page_jump_changed', self.in_menu_changed)
self.wliststore_files.append([new_separator, new_separator.separator_name, True, "", False, _("Page jump")])
self.set_interface_status(None)
self.refresh_disc_usage()
\ No newline at end of file
......@@ -23,19 +23,23 @@ import devedeng.interface_manager
class separator(devedeng.interface_manager.interface_manager):
__gsignals__ = {'name_changed': (GObject.SIGNAL_RUN_FIRST, None, (str,)), 'in_menu_changed': (
__gsignals__ = {'name_changed': (GObject.SIGNAL_RUN_FIRST, None, (str,)), 'page_jump_changed': (
GObject.SIGNAL_RUN_FIRST, None, (bool,))}
def __init__(self):
self.element_type = "separator"
devedeng.interface_manager.interface_manager.__init__(self)
self.add_toggle("show_in_menu", True)
self.add_toggle("page_jump", True)
self.add_text("separator_name", _("Separator"))
def set_name(self, new_name):
self.separator_name = new_name
self.emit('name_changed', self.separator_name)
def set_page_jump(self, page_jump):
self.page_jump = page_jump
self.emit('page_jump_changed', self.page_jump)
def delete_element(self):
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment