aboutsummaryrefslogtreecommitdiffstats
path: root/lvc/widgets/gtk/window.py
diff options
context:
space:
mode:
Diffstat (limited to 'lvc/widgets/gtk/window.py')
-rw-r--r--lvc/widgets/gtk/window.py129
1 files changed, 71 insertions, 58 deletions
diff --git a/lvc/widgets/gtk/window.py b/lvc/widgets/gtk/window.py
index de912cc..18d91a2 100644
--- a/lvc/widgets/gtk/window.py
+++ b/lvc/widgets/gtk/window.py
@@ -45,6 +45,7 @@ import wrappermap
alive_windows = set()
running_dialogs = set()
+
class WrappedWindow(gtk.Window):
def do_map(self):
gtk.Window.do_map(self)
@@ -53,18 +54,20 @@ class WrappedWindow(gtk.Window):
def do_unmap(self):
gtk.Window.do_unmap(self)
wrappermap.wrapper(self).emit('hide')
+
def do_focus_in_event(self, event):
gtk.Window.do_focus_in_event(self, event)
wrappermap.wrapper(self).emit('active-change')
+
def do_focus_out_event(self, event):
gtk.Window.do_focus_out_event(self, event)
wrappermap.wrapper(self).emit('active-change')
def do_key_press_event(self, event):
- if self.activate_key(event): # event activated a menu item
+ if self.activate_key(event): # event activated a menu item
return
- if self.propagate_key_event(event): # event handled by widget
+ if self.propagate_key_event(event): # event handled by widget
return
ret = keymap.translate_gtk_event(event)
@@ -109,6 +112,7 @@ class WrappedWindow(gtk.Window):
gobject.type_register(WrappedWindow)
+
class WindowBase(signals.SignalEmitter):
def __init__(self):
signals.SignalEmitter.__init__(self)
@@ -173,10 +177,9 @@ class Window(WindowBase):
def setup_icon(self):
icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
- resources.image_path("lvc-logo.png"))
+ resources.image_path("lvc-logo.png"))
self._window.set_icon(icon_pixbuf)
-
def accept_file_drag(self, val):
if not val:
self._window.drag_dest_set(0, [], 0)
@@ -189,9 +192,9 @@ class Window(WindowBase):
[('text/uri-list', 0, 0)],
gtk.gdk.ACTION_COPY)
for signal, callback in (
- ('drag-motion', self.on_drag_motion),
- ('drag-data-received', self.on_drag_data_received),
- ('drag-leave', self.on_drag_leave)):
+ ('drag-motion', self.on_drag_motion),
+ ('drag-data-received', self.on_drag_data_received),
+ ('drag-leave', self.on_drag_leave)):
self.drag_signals.append(
self._window.connect(signal, callback))
@@ -329,12 +332,12 @@ class Window(WindowBase):
monitor_geom.y + (position[1] - frame_extents.y))
-
class DialogWindow(Window):
def __init__(self, title, rect=None):
Window.__init__(self, title, rect)
self._window.set_resizable(False)
+
class MainWindow(Window):
def __init__(self, title, rect):
Window.__init__(self, title, rect)
@@ -401,6 +404,7 @@ class DialogBase(WindowBase):
# don't set self._window to None yet. We will unset it when we
# return from the _run() method
+
class Dialog(DialogBase):
def __init__(self, title, description=None):
"""Create a dialog."""
@@ -453,7 +457,7 @@ class Dialog(DialogBase):
response_id = len(self.buttons_to_add)
for text in reversed(self.buttons_to_add):
label = None
- if isinstance(text, tuple): # stock ID, text
+ if isinstance(text, tuple): # stock ID, text
text, label = text
button = self._window.add_button(text, response_id)
if label is not None:
@@ -472,7 +476,7 @@ class Dialog(DialogBase):
if response == gtk.RESPONSE_DELETE_EVENT:
return -1
else:
- return response - 1 # response IDs started at 1
+ return response - 1 # response IDs started at 1
def set_extra_widget(self, widget):
self.extra_widget = widget
@@ -480,6 +484,7 @@ class Dialog(DialogBase):
def get_extra_widget(self):
return self.extra_widget
+
class FileDialogBase(DialogBase):
def _run(self):
ret = self._window.run()
@@ -488,6 +493,7 @@ class FileDialogBase(DialogBase):
self._files = self._window.get_filenames()
return 0
+
class FileOpenDialog(FileDialogBase):
def __init__(self, title):
FileDialogBase.__init__(self)
@@ -532,11 +538,13 @@ class FileOpenDialog(FileDialogBase):
# provide a common interface for file chooser dialogs
get_path = get_filename
+
def set_path(self, path):
# set_filename puts the whole path in the filename field
self._window.set_current_folder(os.path.dirname(path))
self._window.set_current_name(os.path.basename(path))
+
class FileSaveDialog(FileDialogBase):
def __init__(self, title):
FileDialogBase.__init__(self)
@@ -561,11 +569,13 @@ class FileSaveDialog(FileDialogBase):
# provide a common interface for file chooser dialogs
get_path = get_filename
+
def set_path(self, path):
# set_filename puts the whole path in the filename field
self._window.set_current_folder(os.path.dirname(path))
self._window.set_current_name(os.path.basename(path))
+
class DirectorySelectDialog(FileDialogBase):
def __init__(self, title):
FileDialogBase.__init__(self)
@@ -593,6 +603,7 @@ class DirectorySelectDialog(FileDialogBase):
get_path = get_directory
set_path = set_directory
+
class AboutDialog(Dialog):
def __init__(self):
Dialog.__init__(self, "Libre Video Converter")
@@ -604,20 +615,20 @@ class AboutDialog(Dialog):
def build_content(self):
packing_vbox = layout.VBox(spacing=20)
- #icon_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
- # resources.share_path('icons/hicolor/128x128/apps/miro.png'),
- # 48, 48)
- #packing_vbox._widget.pack_start(gtk.image_new_from_pixbuf(icon_pixbuf))
- #if app.config.get(prefs.APP_REVISION_NUM):
- # version = "%s (%s)" % (
- # app.config.get(prefs.APP_VERSION),
- # app.config.get(prefs.APP_REVISION_NUM))
- #else:
- # version = "%s" % app.config.get(prefs.APP_VERSION)
+ # icon_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
+ # resources.share_path('icons/hicolor/128x128/apps/miro.png'),
+ # 48, 48)
+ # packing_vbox._widget.pack_start(gtk.image_new_from_pixbuf(icon_pixbuf))
+ # if app.config.get(prefs.APP_REVISION_NUM):
+ # version = "%s (%s)" % (
+ # app.config.get(prefs.APP_VERSION),
+ # app.config.get(prefs.APP_REVISION_NUM))
+ # else:
+ # version = "%s" % app.config.get(prefs.APP_VERSION)
version = '1.0.1'
- #name_label = gtk.Label(
- # '<span size="xx-large" weight="bold">%s %s</span>' % (
- # app.config.get(prefs.SHORT_APP_NAME), version))
+ # name_label = gtk.Label(
+ # '<span size="xx-large" weight="bold">%s %s</span>' % (
+ # app.config.get(prefs.SHORT_APP_NAME), version))
name_label = gtk.Label(
'<span size="xx-large" weight="bold">%s %s</span>' % (
'Libre Video Converter', version))
@@ -630,52 +641,53 @@ class AboutDialog(Dialog):
packing_vbox._widget.pack_start(copyright_label)
# FIXME - make the project url clickable
- #packing_vbox._widget.pack_start(
- # gtk.Label(app.config.get(prefs.PROJECT_URL)))
+ # packing_vbox._widget.pack_start(
+ # gtk.Label(app.config.get(prefs.PROJECT_URL)))
- #contributor_label = gtk.Label(
- # _("Thank you to all the people who contributed to %(appname)s "
- # "%(version)s:",
- # {"appname": app.config.get(prefs.SHORT_APP_NAME),
- # "version": app.config.get(prefs.APP_VERSION)}))
- #contributor_label.set_justify(gtk.JUSTIFY_CENTER)
- #packing_vbox._widget.pack_start(contributor_label)
+ # contributor_label = gtk.Label(
+ # _("Thank you to all the people who contributed to %(appname)s "
+ # "%(version)s:",
+ # {"appname": app.config.get(prefs.SHORT_APP_NAME),
+ # "version": app.config.get(prefs.APP_VERSION)}))
+ # contributor_label.set_justify(gtk.JUSTIFY_CENTER)
+ # packing_vbox._widget.pack_start(contributor_label)
# get contributors, remove newlines and wrap it
- #contributors = open(resources.path('CREDITS'), 'r').readlines()
- #contributors = [c[2:].strip()
- # for c in contributors if c.startswith("* ")]
- #contributors = ", ".join(contributors)
+ # contributors = open(resources.path('CREDITS'), 'r').readlines()
+ # contributors = [c[2:].strip()
+ # for c in contributors if c.startswith("* ")]
+ # contributors = ", ".join(contributors)
# show contributors
- #contrib_buffer = gtk.TextBuffer()
- #contrib_buffer.set_text(contributors)
-
- #contrib_view = gtk.TextView(contrib_buffer)
- #contrib_view.set_editable(False)
- #contrib_view.set_cursor_visible(False)
- #contrib_view.set_wrap_mode(gtk.WRAP_WORD)
- #contrib_window = gtk.ScrolledWindow()
- #contrib_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
- #contrib_window.add(contrib_view)
- #contrib_window.set_size_request(-1, 100)
- #packing_vbox._widget.pack_start(contrib_window)
+ # contrib_buffer = gtk.TextBuffer()
+ # contrib_buffer.set_text(contributors)
+
+ # contrib_view = gtk.TextView(contrib_buffer)
+ # contrib_view.set_editable(False)
+ # contrib_view.set_cursor_visible(False)
+ # contrib_view.set_wrap_mode(gtk.WRAP_WORD)
+ # contrib_window = gtk.ScrolledWindow()
+ # contrib_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
+ # contrib_window.add(contrib_view)
+ # contrib_window.set_size_request(-1, 100)
+ # packing_vbox._widget.pack_start(contrib_window)
# FIXME - make the project url clickable
- #donate_label = gtk.Label(
- # _("To help fund continued %(appname)s development, visit the "
- # "donation page at:",
- # {"appname": app.config.get(prefs.SHORT_APP_NAME)}))
- #donate_label.set_justify(gtk.JUSTIFY_CENTER)
- #packing_vbox._widget.pack_start(donate_label)
-
- #packing_vbox._widget.pack_start(
- # gtk.Label(app.config.get(prefs.DONATE_URL)))
+ # donate_label = gtk.Label(
+ # _("To help fund continued %(appname)s development, visit the "
+ # "donation page at:",
+ # {"appname": app.config.get(prefs.SHORT_APP_NAME)}))
+ # donate_label.set_justify(gtk.JUSTIFY_CENTER)
+ # packing_vbox._widget.pack_start(donate_label)
+
+ # packing_vbox._widget.pack_start(
+ # gtk.Label(app.config.get(prefs.DONATE_URL)))
return packing_vbox
def on_contrib_link_event(self, texttag, widget, event, iter_):
if event.type == gtk.gdk.BUTTON_PRESS:
- resources.open_url('https://notabug.org/heckyel/librevideoconverter')
+ resources.open_url(
+ 'https://notabug.org/heckyel/librevideoconverter')
type_map = {
0: gtk.MESSAGE_WARNING,
@@ -683,6 +695,7 @@ type_map = {
2: gtk.MESSAGE_ERROR
}
+
class AlertDialog(DialogBase):
def __init__(self, title, description, alert_type):
DialogBase.__init__(self)