diff options
author | rowanbeentje <rowan@beent.je> | 2010-06-14 21:20:40 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-06-14 21:20:40 +0000 |
commit | ce0bde25cb5388aeb33e57883e7da89473086417 (patch) | |
tree | a2c91ca879e15a8f809361a5a5d1a18ee4e603de /Source/SPTablesList.m | |
parent | 6e1a24c45eb99a9c9f8e1cb708b64bdc504d5efe (diff) | |
download | sequelpro-ce0bde25cb5388aeb33e57883e7da89473086417.tar.gz sequelpro-ce0bde25cb5388aeb33e57883e7da89473086417.tar.bz2 sequelpro-ce0bde25cb5388aeb33e57883e7da89473086417.zip |
- Convert connection encoding menus to be menu tag based to fix localisation errors
- Add database encoding retrieval support for MySQL 4.1
- Convert the add table and add database sheets to use encoding menus derived from server supported encodings
- Re-layout preferences with larger labels to aid localisation
- Fix preference resizing in non-Favorite tabs
Diffstat (limited to 'Source/SPTablesList.m')
-rw-r--r-- | Source/SPTablesList.m | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 498a5166..509e3b83 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -287,6 +287,35 @@ [tableTypeButton addItemWithTitle:[engine objectForKey:@"Engine"]]; } + // Populate the table encoding popup button with a default menu item + [tableEncodingButton removeAllItems]; + [tableEncodingButton addItemWithTitle:@"Default"]; + + // Retrieve the server-supported encodings and add them to the menu + NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings]; + NSString *utf8MenuItemTitle = nil; + if ([encodings count] > 0 + && ([mySQLConnection serverMajorVersion] > 4 + || ([mySQLConnection serverMajorVersion] == 4 && [mySQLConnection serverMinorVersion] >= 1))) + { + [[tableEncodingButton menu] addItem:[NSMenuItem separatorItem]]; + for (NSDictionary *encoding in encodings) { + NSString *menuItemTitle = (![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]; + [tableEncodingButton addItemWithTitle:menuItemTitle]; + + // If the UTF8 entry has been encountered, store the menu title + if ([[encoding objectForKey:@"CHARACTER_SET_NAME"] isEqualToString:@"utf8"]) { + utf8MenuItemTitle = [NSString stringWithString:menuItemTitle]; + } + } + + // If a UTF8 entry was found, promote it to the top of the list + if (utf8MenuItemTitle) { + [[tableEncodingButton menu] insertItem:[NSMenuItem separatorItem] atIndex:2]; + [tableEncodingButton insertItemWithTitle:utf8MenuItemTitle atIndex:2]; + } + } + [NSApp beginSheet:tableSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self @@ -675,7 +704,7 @@ // If encoding is set to Autodetect, update the connection character set encoding // based on the newly selected table's encoding - but only if it differs from the current encoding. - if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPDefaultEncoding] isEqualToString:@"Autodetect"]) { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPDefaultEncoding] intValue] == SPEncodingAutodetect) { if (tableEncoding != nil && ![tableEncoding isEqualToString:[tableDocumentInstance connectionEncoding]]) { [tableDocumentInstance setConnectionEncoding:tableEncoding reloadingViews:NO]; [tableDataInstance resetAllData]; @@ -2033,7 +2062,7 @@ // If there is an encoding selected other than the default we must specify it in CREATE TABLE statement if ([tableEncodingButton indexOfSelectedItem] > 0) { - charSetStatement = [NSString stringWithFormat:@"DEFAULT CHARACTER SET %@", [[tableDocumentInstance mysqlEncodingFromDisplayEncoding:[tableEncodingButton title]] backtickQuotedString]]; + charSetStatement = [NSString stringWithFormat:@"DEFAULT CHARACTER SET %@", [[tableDocumentInstance mysqlEncodingFromEncodingTag:[tableEncodingButton tag]] backtickQuotedString]]; } // If there is a type selected other than the default we must specify it in CREATE TABLE statement |