[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Add internal handling of setting artwork url in VLCInformationWindowController

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Jul 8 16:16:52 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
4409f29e by Claudio Cambra at 2023-07-08T15:50:23+00:00
macosx: Add internal handling of setting artwork url in VLCInformationWindowController

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
55e75415 by Claudio Cambra at 2023-07-08T15:50:23+00:00
macosx: Add a setter method for artworkMRL property in VLCInputItem

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
52d64c03 by Claudio Cambra at 2023-07-08T15:50:23+00:00
macosx: Replace artwork iamge view with image button, connect to image selection methods

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
f7c3a6fb by Claudio Cambra at 2023-07-08T15:50:23+00:00
macosx: Fix VLCInputItem artowrkURL setter

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


5 changed files:

- modules/gui/macosx/UI/VLCInformationWindow.xib
- modules/gui/macosx/library/VLCInputItem.h
- modules/gui/macosx/library/VLCInputItem.m
- modules/gui/macosx/panels/VLCInformationWindowController.h
- modules/gui/macosx/panels/VLCInformationWindowController.m


Changes:

=====================================
modules/gui/macosx/UI/VLCInformationWindow.xib
=====================================
@@ -14,7 +14,7 @@
                 <outlet property="albumTextField" destination="439" id="Rih-lX-lJW"/>
                 <outlet property="artistLabel" destination="432" id="Iu0-7V-KXV"/>
                 <outlet property="artistTextField" destination="431" id="pCd-jk-UrD"/>
-                <outlet property="artworkImageView" destination="9Mp-s6-NGc" id="98x-Ub-eP0"/>
+                <outlet property="artworkImageButton" destination="9jw-Fr-d1M" id="Iz3-tl-NGZ"/>
                 <outlet property="audioDecodedLabel" destination="583" id="684"/>
                 <outlet property="audioDecodedTextField" destination="582" id="685"/>
                 <outlet property="audioLabel" destination="574" id="686"/>
@@ -441,22 +441,33 @@
                                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                             </textFieldCell>
                                         </textField>
-                                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="9Mp-s6-NGc" customClass="VLCImageView">
-                                            <rect key="frame" x="345" y="129" width="160" height="121"/>
-                                        </customView>
+                                        <button translatesAutoresizingMaskIntoConstraints="NO" id="9jw-Fr-d1M">
+                                            <rect key="frame" x="345" y="129" width="160" height="128"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="128" id="sbu-BX-HX7"/>
+                                            </constraints>
+                                            <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="noart" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="T6o-O9-fdd">
+                                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                                <font key="font" metaFont="system"/>
+                                            </buttonCell>
+                                            <connections>
+                                                <action selector="chooseArtwork:" target="-2" id="aoX-w0-3xf"/>
+                                            </connections>
+                                        </button>
                                     </subviews>
                                     <constraints>
                                         <constraint firstItem="32r-kK-YIK" firstAttribute="centerY" secondItem="NFO-5i-C2y" secondAttribute="centerY" id="1fr-ua-HLh"/>
                                         <constraint firstItem="498" firstAttribute="leading" secondItem="487" secondAttribute="leading" id="2BM-dO-cxA"/>
                                         <constraint firstItem="TJe-7E-Uca" firstAttribute="baseline" secondItem="NFO-5i-C2y" secondAttribute="baseline" id="38c-hf-AdS"/>
+                                        <constraint firstItem="9jw-Fr-d1M" firstAttribute="leading" secondItem="KiB-XA-gnh" secondAttribute="leading" id="38t-tH-IXh"/>
                                         <constraint firstItem="412" firstAttribute="top" secondItem="504" secondAttribute="bottom" constant="7" id="3sc-H3-Jb7"/>
                                         <constraint firstItem="Cro-Nn-BBH" firstAttribute="leading" secondItem="Vvu-VZ-aui" secondAttribute="trailing" constant="8" id="4Wy-de-qFK"/>
                                         <constraint firstItem="435" firstAttribute="top" secondItem="436" secondAttribute="bottom" constant="3" id="5A4-pd-kbP"/>
                                         <constraint firstItem="463" firstAttribute="leading" secondItem="461" secondAttribute="trailing" constant="8" id="5fW-BF-CQQ"/>
                                         <constraint firstAttribute="trailing" secondItem="435" secondAttribute="trailing" constant="37" id="5sT-kX-Mgh"/>
                                         <constraint firstItem="435" firstAttribute="leading" secondItem="431" secondAttribute="trailing" constant="8" id="69n-nP-QoU"/>
-                                        <constraint firstItem="9Mp-s6-NGc" firstAttribute="bottom" secondItem="486" secondAttribute="bottom" id="6RC-cE-vQo"/>
                                         <constraint firstItem="439" firstAttribute="top" secondItem="440" secondAttribute="bottom" constant="3" id="71b-yF-M2B"/>
+                                        <constraint firstItem="9jw-Fr-d1M" firstAttribute="bottom" secondItem="486" secondAttribute="bottom" id="77b-m1-E2f"/>
                                         <constraint firstItem="Ken-fu-rsj" firstAttribute="leading" secondItem="441" secondAttribute="trailing" constant="8" id="8CH-DT-qPt"/>
                                         <constraint firstItem="440" firstAttribute="leading" secondItem="462" secondAttribute="leading" id="8gB-xE-tw2"/>
                                         <constraint firstItem="481" firstAttribute="height" secondItem="504" secondAttribute="height" id="8qb-HX-DzD"/>
@@ -465,6 +476,7 @@
                                         <constraint firstItem="463" firstAttribute="top" secondItem="464" secondAttribute="bottom" constant="3" id="AWB-mE-B6y"/>
                                         <constraint firstItem="Vvu-VZ-aui" firstAttribute="top" secondItem="TJe-7E-Uca" secondAttribute="bottom" constant="3" id="BBb-mj-Qf6"/>
                                         <constraint firstItem="D3W-el-Mmk" firstAttribute="top" secondItem="32r-kK-YIK" secondAttribute="bottom" constant="3" id="BQW-oc-WnH"/>
+                                        <constraint firstItem="9jw-Fr-d1M" firstAttribute="top" secondItem="463" secondAttribute="bottom" constant="8" id="BUu-AV-Vnk"/>
                                         <constraint firstItem="482" firstAttribute="leading" secondItem="481" secondAttribute="leading" id="BbW-Tt-gK9"/>
                                         <constraint firstItem="498" firstAttribute="trailing" secondItem="477" secondAttribute="trailing" id="Bgv-0D-P34"/>
                                         <constraint firstItem="TJe-7E-Uca" firstAttribute="top" secondItem="439" secondAttribute="bottom" constant="8" id="CtI-Qn-zYS"/>
@@ -472,9 +484,7 @@
                                         <constraint firstItem="476" firstAttribute="width" secondItem="461" secondAttribute="width" id="DI2-7l-jjc"/>
                                         <constraint firstItem="440" firstAttribute="leading" secondItem="439" secondAttribute="leading" id="DKW-vC-4a2"/>
                                         <constraint firstItem="KiB-XA-gnh" firstAttribute="leading" secondItem="cXh-Kb-cBh" secondAttribute="leading" id="E5O-E7-sp2"/>
-                                        <constraint firstItem="9Mp-s6-NGc" firstAttribute="trailing" secondItem="463" secondAttribute="trailing" id="Ecd-2i-8vs"/>
                                         <constraint firstItem="442" firstAttribute="leading" secondItem="441" secondAttribute="leading" id="F2a-9d-qnp"/>
-                                        <constraint firstItem="9Mp-s6-NGc" firstAttribute="width" secondItem="463" secondAttribute="width" id="Fb3-6O-ryV"/>
                                         <constraint firstItem="429" firstAttribute="leading" secondItem="427" secondAttribute="leading" id="FdL-JK-SXm"/>
                                         <constraint firstItem="tWC-Zr-8E5" firstAttribute="top" secondItem="8ES-YK-OvS" secondAttribute="bottom" constant="3" id="G4x-Vv-Wua"/>
                                         <constraint firstItem="504" firstAttribute="leading" secondItem="481" secondAttribute="trailing" constant="8" id="GNl-FV-0Tb"/>
@@ -509,6 +519,7 @@
                                         <constraint firstItem="440" firstAttribute="baseline" secondItem="442" secondAttribute="baseline" id="ZR6-uA-mI7"/>
                                         <constraint firstItem="Ken-fu-rsj" firstAttribute="top" secondItem="cIj-bq-nFH" secondAttribute="bottom" constant="3" id="ZUi-DU-CXL"/>
                                         <constraint firstAttribute="trailing" secondItem="427" secondAttribute="trailing" constant="37" id="ZUo-m6-vIM"/>
+                                        <constraint firstItem="9jw-Fr-d1M" firstAttribute="trailing" secondItem="463" secondAttribute="trailing" id="aJT-G3-enV"/>
                                         <constraint firstItem="432" firstAttribute="top" secondItem="427" secondAttribute="bottom" constant="8" id="b5k-Mg-gUI"/>
                                         <constraint firstItem="431" firstAttribute="top" secondItem="432" secondAttribute="bottom" constant="3" id="bNy-JF-PIC"/>
                                         <constraint firstItem="cXh-Kb-cBh" firstAttribute="baseline" secondItem="8ES-YK-OvS" secondAttribute="baseline" id="bXf-GW-PkM"/>
@@ -525,11 +536,10 @@
                                         <constraint firstItem="477" firstAttribute="top" secondItem="461" secondAttribute="bottom" constant="8" symbolic="YES" id="g6g-Ns-JmP"/>
                                         <constraint firstItem="487" firstAttribute="trailing" secondItem="498" secondAttribute="trailing" id="gE5-M8-JCo"/>
                                         <constraint firstItem="D3W-el-Mmk" firstAttribute="trailing" secondItem="Ken-fu-rsj" secondAttribute="trailing" id="gJK-xx-0fy"/>
+                                        <constraint firstItem="9jw-Fr-d1M" firstAttribute="width" secondItem="463" secondAttribute="width" id="gsO-On-Rim"/>
                                         <constraint firstAttribute="trailing" secondItem="510" secondAttribute="trailing" constant="34" id="hlm-Bz-jEa"/>
                                         <constraint firstItem="441" firstAttribute="leading" secondItem="463" secondAttribute="leading" id="ikh-TH-cNg"/>
-                                        <constraint firstItem="9Mp-s6-NGc" firstAttribute="width" secondItem="KiB-XA-gnh" secondAttribute="width" id="jay-oH-mXL"/>
                                         <constraint firstItem="464" firstAttribute="baseline" secondItem="462" secondAttribute="baseline" id="kmE-pS-llX"/>
-                                        <constraint firstItem="9Mp-s6-NGc" firstAttribute="top" secondItem="463" secondAttribute="bottom" constant="8" id="l3G-gN-0Wb"/>
                                         <constraint firstItem="498" firstAttribute="top" secondItem="476" secondAttribute="bottom" constant="8" id="lwM-dZ-Ak0"/>
                                         <constraint firstItem="441" firstAttribute="centerY" secondItem="439" secondAttribute="centerY" id="m5s-7J-bmT"/>
                                         <constraint firstItem="497" firstAttribute="height" secondItem="476" secondAttribute="height" id="mNu-5I-ZC9"/>
@@ -588,7 +598,7 @@
                                                                 </textFieldCell>
                                                                 <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
                                                             </tableColumn>
-                                                            <tableColumn identifier="1" editable="NO" width="262" minWidth="10" maxWidth="3.4028234663852886e+38" id="644">
+                                                            <tableColumn identifier="1" editable="NO" width="233" minWidth="10" maxWidth="3.4028234663852886e+38" id="644">
                                                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
                                                                     <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                                                     <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
@@ -1099,4 +1109,7 @@
             <point key="canvasLocation" x="139" y="148"/>
         </window>
     </objects>
+    <resources>
+        <image name="noart" width="128" height="128"/>
+    </resources>
 </document>


=====================================
modules/gui/macosx/library/VLCInputItem.h
=====================================
@@ -71,7 +71,7 @@ extern NSString *VLCInputItemPreparsingSucceeded;
 @property (readonly) vlc_tick_t duration;
 @property (readonly) enum input_item_type_e inputType;
 @property (readonly) struct input_item_node_t *subTree;
- at property (readonly) NSURL *artworkURL;
+ at property (readwrite) NSURL *artworkURL;
 @property (readonly) BOOL preparsed;
 @property (readonly) BOOL isStream;
 


=====================================
modules/gui/macosx/library/VLCInputItem.m
=====================================
@@ -501,6 +501,19 @@ static const struct vlc_metadata_cbs preparseCallbacks = {
     return nil;
 }
 
+- (void)setArtworkURL:(NSURL *)artworkURL
+{
+    if (!_vlcInputItem) {
+        return;
+    }
+
+    if (artworkURL != nil) {
+        input_item_SetArtworkURL(_vlcInputItem, artworkURL.absoluteString.UTF8String);
+    } else {
+        input_item_SetArtworkURL(_vlcInputItem, NULL);
+    }
+}
+
 - (void)parseInputItem
 {
     _p_parserID = input_item_Parse(_vlcInputItem,


=====================================
modules/gui/macosx/panels/VLCInformationWindowController.h
=====================================
@@ -71,7 +71,7 @@
 @property (readwrite, weak) IBOutlet VLCSettingTextField *actorsTextField;
 @property (readwrite, weak) IBOutlet NSTextField *directorLabel;
 @property (readwrite, weak) IBOutlet VLCSettingTextField *directorTextField;
- at property (readwrite, weak) IBOutlet VLCImageView *artworkImageView;
+ at property (readwrite, weak) IBOutlet NSButton *artworkImageButton;
 @property (readwrite, weak) IBOutlet NSButton *saveMetaDataButton;
 
 @property (readwrite, weak) IBOutlet NSTextField *audioLabel;
@@ -113,6 +113,7 @@
 
 - (IBAction)toggleWindow:(id)sender;
 - (IBAction)saveMetaData:(id)sender;
+- (IBAction)chooseArtwork:(id)sender;
 
 - (void)setRepresentedInputItem:(VLCInputItem *)representedInputItem;
 - (void)setRepresentedMediaLibraryAudioGroup:(id<VLCMediaLibraryAudioGroupProtocol>)representedMediaLibraryAudioGroup;


=====================================
modules/gui/macosx/panels/VLCInformationWindowController.m
=====================================
@@ -88,6 +88,7 @@ actionCallback(encodedBy);
 {
     VLCCodecInformationTreeItem *_rootCodecInformationItem;
     NSImage *_artwork;
+    NSURL *_newArtworkURL;
     BOOL _statisticsEnabled;
 }
 @end
@@ -348,7 +349,7 @@ _##field##TextField.delegate = self
 
 #undef FILL_FIELD_FROM_INPUTITEM
 
-    _artworkImageView.image = _artwork;
+    _artworkImageButton.image = _artwork;
 
     if (!_mainMenuInstance) {
         [self.window setTitle:inputItem.title];
@@ -375,12 +376,15 @@ _##field##TextField.delegate = self
     
 #undef FILL_FIELD_FROM_DICT
 
-    _artworkImageView.image = _artwork;
+    _artworkImageButton.image = _artwork;
 }
 
 - (void)updateRepresentation
 {
     _saveMetaDataButton.enabled = NO;
+    _newArtworkURL = nil;
+    _artworkImageButton.image = _artwork;
+    _artworkImageButton.alternateImage = _artwork;
 
     if (_representedInputItems.count == 0) {
         /* Erase */
@@ -390,7 +394,7 @@ _##field##TextField.originalStateString = @"";
         PERFORM_ACTION_ALL_TEXTFIELDS(CLEAR_TEXT);
 
 #undef CLEAR_TEXT
-        [_artworkImageView setImage:[NSImage imageNamed:@"noart.png"]];
+        _artworkImageButton.image = [NSImage imageNamed:@"noart.png"];
     } else if (_representedInputItems.count == 1) {
         [self fillWindowWithInputItemData:_representedInputItems.firstObject];
     } else if (_representedInputItems.count > 1) {
@@ -468,6 +472,8 @@ settingsChanged = settingsChanged || _##field##TextField.settingChanged;
     PERFORM_ACTION_ALL_TEXTFIELDS(CHECK_FIELD_SETTING_CHANGED);
 
 #undef CHECK_FIELD_SETTING_CHANGED
+
+    settingsChanged = settingsChanged || _newArtworkURL != nil;
     
     _saveMetaDataButton.enabled = settingsChanged;
 }
@@ -488,9 +494,13 @@ settingsChanged = settingsChanged || _##field##TextField.settingChanged;
 SET_INPUTITEM_PROP(field, field)                \
     
     for (VLCInputItem * const inputItem in inputItems) {
-        SET_INPUTITEM_PROP(title, name);
+        SET_INPUTITEM_PROP(title, name); // Input items do not have a title field
         PERFORM_ACTION_READWRITE_TEXTFIELDS(SET_INPUTITEM_MATCHING_PROP);
 
+        if (_newArtworkURL != nil) { // Artwork urls require their own handling
+            inputItem.artworkURL = _newArtworkURL;
+        }
+
         [inputItem writeMetadataToFile];
     }
 
@@ -513,6 +523,36 @@ SET_INPUTITEM_PROP(field, field)                \
     }
 }
 
+- (IBAction)chooseArtwork:(id)sender
+{
+    NSOpenPanel * const panel = [NSOpenPanel openPanel];
+    [panel setAllowedFileTypes:@[@"png", @"jpg", @"jpeg", @"gif", @"tiff", @"tif", @"bmp"]];
+    [panel setAllowsMultipleSelection:NO];
+    [panel setCanChooseDirectories:NO];
+    [panel setCanChooseFiles:YES];
+    [panel setCanCreateDirectories:NO];
+    [panel setResolvesAliases:YES];
+    [panel setAllowsOtherFileTypes:NO];
+    [panel setPrompt:_NS("Choose")];
+    [panel beginSheetModalForWindow:self.window completionHandler:^(const NSInteger result) {
+        if (result != NSFileHandlingPanelOKButton) {
+            return;
+        }
+
+        NSURL * const url = panel.URLs.firstObject;
+        NSImage * const image = [[NSImage alloc] initWithContentsOfURL:url];
+        if (!image) {
+            return;
+        }
+
+        _artwork = image;
+        _artworkImageButton.image = [[NSImage alloc] initWithContentsOfURL:url];
+
+        _newArtworkURL = url;
+        _saveMetaDataButton.enabled = YES;
+    }];
+}
+
 @end
 
 @implementation VLCInformationWindowController (NSTableDataSource)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a66b4e82a709e260fa7590dc45b0215529a00f07...f7c3a6fb7d56f05f0d7baea8ab26b75cf585bb68

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a66b4e82a709e260fa7590dc45b0215529a00f07...f7c3a6fb7d56f05f0d7baea8ab26b75cf585bb68
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list