diff --git a/src/glade/editmediaref.glade b/src/glade/editmediaref.glade index 457e3384e..c8f143739 100644 --- a/src/glade/editmediaref.glade +++ b/src/glade/editmediaref.glade @@ -16,7 +16,6 @@ True 6 - vertical 6 @@ -26,7 +25,7 @@ True 12 - 4 + 5 5 12 6 @@ -41,7 +40,7 @@ 2 3 4 - GTK_FILL + @@ -56,7 +55,7 @@ 4 3 4 - GTK_FILL + @@ -79,8 +78,8 @@ True True - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. + If media is an image, select the specific part of the image you want to reference. +You can use the mouse on the picture to select a region, or use these spinbuttons to set the top left, and bottom right corner of the referenced region. Point (0,0) is the top left corner of the picture, and (100,100) the bottom right corner. adjustment4 1 @@ -98,8 +97,9 @@ True True - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. + If media is an image, select the specific part of the image you want to reference. +You can use the mouse on the picture to select a region, or use these spinbuttons to set the top left, and bottom right corner of the referenced region. Point (0,0) is the top left corner of the picture, and (100,100) the bottom right corner. + adjustment3 1 @@ -116,6 +116,8 @@ True + Referenced region of the image media object. +Select a region with clicking and holding the mouse button on the top left corner of the region you want, dragging the mouse to the bottom right corner of the region, and then releasing the mouse button. 0 @@ -125,6 +127,7 @@ 100 100 True + 0 @@ -139,9 +142,8 @@ 2 - 4 - GTK_FILL - GTK_FILL + 5 + @@ -155,7 +157,7 @@ 2 2 3 - GTK_FILL + @@ -163,8 +165,9 @@ True True - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. + If media is an image, select the specific part of the image you want to reference. +You can use the mouse on the picture to select a region, or use these spinbuttons to set the top left, and bottom right corner of the referenced region. Point (0,0) is the top left corner of the picture, and (100,100) the bottom right corner. + adjustment2 1 @@ -182,8 +185,8 @@ True True - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. - If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use. + If media is an image, select the specific part of the image you want to reference. +You can use the mouse on the picture to select a region, or use these spinbuttons to set the top left, and bottom right corner of the referenced region. Point (0,0) is the top left corner of the picture, and (100,100) the bottom right corner. adjustment1 1 @@ -208,29 +211,74 @@ 4 2 3 - GTK_FILL + - + + True + + + 2 + 3 + 4 + 5 + + + + True - True - True - + True - gtk-dialog-authentication - 1 + True + True + none + + + True + gtk-dialog-authentication + 1 + + + + False + False + end + 0 + + 4 5 - - + GTK_FILL + GTK_EXPAND + + + + + + + + + + + + + + + + + + + + + @@ -272,7 +320,6 @@ _Path: True center - path 1 @@ -321,6 +368,7 @@ True True + Descriptive title for this media object. @@ -331,20 +379,6 @@ - - - True - True - - - - 2 - 3 - 2 - 3 - - - 6 @@ -356,11 +390,14 @@ 6 + False + False 0 + 400 True 0 3 @@ -436,6 +473,7 @@ True + Type of media object as indicated by the computer, eg Image, Video, ... 0 @@ -455,6 +493,7 @@ True True + A unique ID to identify the Media object. @@ -466,6 +505,7 @@ True True True + none True @@ -488,6 +528,49 @@ GTK_FILL + + + True + 12 + + + True + True + + + + 0 + + + + + True + True + True + none + + + True + gtk-open + 1 + + + + + False + False + 1 + + + + + 2 + 3 + 2 + 3 + + + diff --git a/src/gui/editors/editmediaref.py b/src/gui/editors/editmediaref.py index bbfe4470c..b633bb2eb 100644 --- a/src/gui/editors/editmediaref.py +++ b/src/gui/editors/editmediaref.py @@ -94,25 +94,51 @@ class EditMediaRef(EditReference): self.primtab = RefTab(self.dbstate, self.uistate, self.track, _('_General'), tblref) + def setup_filepath(self): + self.select = self.top.get_object('file_select') + self.file_path = self.top.get_object("path") + + self.file_path.set_text(self.source.get_path()) + self.select.connect('clicked', self.select_file) + + def determine_mime(self): + descr = gen.mime.get_description(self.source.get_mime_type()) + if descr: + self.mimetext.set_text(descr) + + path = self.file_path.get_text() + path_full = Utils.media_path_full(self.db, path) + if path != self.source.get_path() and path_full != self.source.get_path(): + #redetermine mime + mime = gen.mime.get_type(Utils.find_file(path_full)) + self.source.set_mime_type(mime) + descr = gen.mime.get_description(mime) + if descr: + self.mimetext.set_text(descr) + else: + self.mimetext.set_text(_('Unknown')) + #if mime type not set, is note + if not self.source.get_mime_type(): + self.mimetext.set_text(_('Note')) + def draw_preview(self): """ Draw the two preview images. This method can be called on eg change of the path. """ - self.mtype = self.source.get_mime_type() - fullpath = Utils.media_path_full(self.db, self.source.get_path()) - self.pix = ThumbNails.get_thumbnail_image(fullpath, - self.mtype) - self.pixmap.set_from_pixbuf(self.pix) - - self.subpix = ThumbNails.get_thumbnail_image(fullpath, - self.mtype, - self.rectangle) - self.subpixmap.set_from_pixbuf(self.subpix) + mtype = self.source.get_mime_type() + if mtype: + fullpath = Utils.media_path_full(self.db, self.source.get_path()) + pb = ThumbNails.get_thumbnail_image(fullpath, mtype) + self.pixmap.set_from_pixbuf(pb) + subpix = ThumbNails.get_thumbnail_image(fullpath, mtype, + self.rectangle) + self.subpixmap.set_from_pixbuf(subpix) + else: + pb = ThumbNails.find_mime_type_pixbuf('text/plain') + self.pixmap.set_from_pixbuf(pb) + self.subpixmap.set_from_pixbuf(pb) - mt = gen.mime.get_description(self.mtype) - self.top.get_object("type").set_text(mt if mt else "") - def _setup_fields(self): ebox_shared = self.top.get_object('eventbox') ebox_shared.connect('button-press-event', self.button_press_event) @@ -127,6 +153,7 @@ class EditMediaRef(EditReference): ebox_ref.add_events(gtk.gdk.BUTTON_RELEASE_MASK) self.pixmap = self.top.get_object("pixmap") + self.mimetext = self.top.get_object("type") coord = self.source_ref.get_rectangle() #upgrade path: set invalid (from eg old db) to none @@ -141,6 +168,8 @@ class EditMediaRef(EditReference): self.rectangle = coord self.subpixmap = self.top.get_object("subpixmap") + self.setup_filepath() + self.determine_mime() self.draw_preview() corners = ["corner1_x", "corner1_y", "corner2_x", "corner2_y"] @@ -468,8 +497,16 @@ class EditMediaRef(EditReference): """ for obj in (self.descr_window, self.path_obj): obj.update() + self.determine_mime() self.draw_preview() + def select_file(self, val): + self.determine_mime() + path = self.file_path.get_text() + self.source.set_path(Utils.get_unicode_path_from_file_chooser(path)) + AddMediaObject(self.dbstate, self.uistate, self.track, self.source, + self._update_addmedia) + def _connect_signals(self): self.define_cancel_button(self.top.get_object('button84')) self.define_ok_button(self.top.get_object('button82'),self.save)