26
26
from os import path
27
from xml.sax import saxutils
30
28
from gettext import gettext as _
31
from xml.sax import saxutils
30
from gi.repository import Gtk, Pango, GConf
34
33
NO_DIALOG = '/apps/dmedia/dont-show-import-firstrun'
35
conf = gconf.client_get_default()
34
conf = GConf.Client.get_default()
38
37
TITLE = _('DMedia Importer')
40
ICON_SIZE = gtk.ICON_SIZE_LARGE_TOOLBAR
39
ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR
54
class VBox(gtk.VBox, EasyBox):
58
class HBox(gtk.HBox, EasyBox):
62
class Label(gtk.Label):
53
class VBox(Gtk.VBox, EasyBox):
57
class HBox(Gtk.HBox, EasyBox):
61
class Label(Gtk.Label):
64
63
A more convenient label borrowed from TymeLapse.
97
96
self.set_text(text)
100
class Button(gtk.Button):
99
class Button(Gtk.Button):
101
100
def __init__(self, stock=None, text=None):
102
101
super(Button, self).__init__()
105
self._image = gtk.Image()
104
self._image = Gtk.Image()
106
105
self._label = Label(None)
107
106
hbox._pack(self._image)
108
107
hbox._pack(self._label, expand=True)
121
120
class FolderChooser(Button):
122
121
def __init__(self):
123
super(FolderChooser, self).__init__(stock=gtk.STOCK_OPEN)
124
self._label.set_ellipsize(pango.ELLIPSIZE_START)
122
super(FolderChooser, self).__init__(stock=Gtk.STOCK_OPEN)
123
self._label.set_ellipsize(Pango.EllipsizeMode.START)
125
124
self._title = _('Choose folder to import...')
126
125
self.connect('clicked', self._on_clicked)
127
126
self._set_value(os.environ['HOME'])
131
130
self._label._set_text(self._value)
133
132
def _on_clicked(self, button):
134
dialog = gtk.FileChooserDialog(
133
dialog = Gtk.FileChooserDialog(
135
134
title=self._title,
136
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
135
action=Gtk.FileChooserAction.SELECT_FOLDER,
138
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
139
gtk.STOCK_OPEN, gtk.RESPONSE_OK,
137
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
138
Gtk.STOCK_OPEN, Gtk.ResponseType.OK,
142
141
dialog.set_current_folder(self._value)
143
142
response = dialog.run()
144
if response == gtk.RESPONSE_OK:
143
if response == Gtk.ResponseType.OK:
145
144
self._set_value(dialog.get_filename())
149
148
def okay_button():
150
return Button(gtk.STOCK_OK, _('OK, Import Files'))
153
class ImportDialog(gtk.Window):
149
return Button(Gtk.STOCK_OK, _('OK, Import Files'))
152
class ImportDialog(Gtk.Window):
154
153
def __init__(self):
155
154
super(ImportDialog, self).__init__()
156
155
self.set_default_size(425, 200)
184
183
return self._value
186
185
def _on_clicked(self, button):
187
186
self._value = self._folder._value
191
class FirstRunGUI(gtk.Window):
190
class FirstRunGUI(Gtk.Window):
193
192
Promt use first time dmedia importer is run.
197
>>> from dmedia.firstrun import FirstRunGUI
196
>>> from dmedia.gtkui.firstrun import FirstRunGUI
198
197
>>> run = FirstRunGUI.run_if_first_run('/media/EOS_DIGITAL') #doctest: +SKIP
226
225
vbox._pack(label2)
228
227
self.folder = Label(None, 'b')
229
self.folder.set_ellipsize(pango.ELLIPSIZE_START)
228
self.folder.set_ellipsize(Pango.EllipsizeMode.START)
230
229
vbox._pack(self.folder)
232
self.dont_show_again = gtk.CheckButton(label=_("Don't show this again"))
231
self.dont_show_again = Gtk.CheckButton(label=_("Don't show this again"))
233
232
self.dont_show_again.set_active(True)
235
234
self.ok = okay_button()