Skip to content

Commit

Permalink
enable initial implementation of Services preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
trunkmaster committed Apr 21, 2024
1 parent 02acd26 commit 7bd54a8
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Applications/Preferences/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ SUBPROJECTS = \
Modules/Keyboard \
Modules/Mouse \
Modules/Sound \
Modules/Services \
Modules/Expert
# Modules/Date \
# Modules/Menu \
# Modules/Services \
# Modules/Password \
# Modules/Power

Expand All @@ -39,10 +39,10 @@ $(APP_NAME)_RESOURCE_FILES = \
Modules/Keyboard/Keyboard.preferences \
Modules/Mouse/Mouse.preferences \
Modules/Sound/Sound.preferences \
Modules/Services/Services.preferences \
Modules/Expert/Expert.preferences
# Modules/Date/Date.preferences \
# Modules/Menu/Menu.preferences \
# Modules/Services/Services.preferences \
# Modules/Password/Password.preferences \
# Modules/Power/Power.preferences

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"setSeriviceState:"
);
Super = NSObject;
};
Services = {
Actions = (
"setSeriviceState:"
);
Outlets = (
view,
window
window,
actionButton,
servicesList
);
Super = NSObject;
};
Expand Down
Binary file not shown.
11 changes: 8 additions & 3 deletions Applications/Preferences/Modules/Services/Services.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Project: Preferences
//
// Copyright (C) 2014-2019 Sergii Stoian
// Copyright (C) 2014-present Sergii Stoian
// Copyright (C) 2022-2023 Andres Morales
//
// This application is free software; you can redistribute it and/or
Expand All @@ -20,15 +20,20 @@
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
//

#import <AppKit/NSImage.h>
#import <AppKit/AppKit.h>
#import <GNUstepGUI/GSServicesManager.h>

#import <Preferences.h>

@interface Services: NSObject <PrefsModule>
{
NSImage *image;
id view;
id window;
id servicesList;
id actionButton;

NSImage *image;
GSServicesManager *serviceManager;
}

@end
Expand Down
79 changes: 53 additions & 26 deletions Applications/Preferences/Modules/Services/Services.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,19 @@
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
//

#import <AppKit/NSApplication.h>
#import <AppKit/NSNibLoading.h>
#import <AppKit/NSView.h>
#import <AppKit/NSBox.h>
#import <AppKit/NSImage.h>
#import <AppKit/NSButton.h>
#import <AppKit/NSTableView.h>
#import <AppKit/NSTableColumn.h>
#import <AppKit/NSBrowser.h>
#import <AppKit/NSMatrix.h>

#import "Services.h"
#include "Foundation/NSDictionary.h"
#include "Foundation/NSObjCRuntime.h"
#include "GNUstepGUI/GSServicesManager.h"

@implementation Services

static NSBundle *bundle = nil;
static NSUserDefaults *defaults = nil;
static NSMutableDictionary *domain = nil;
static NSBundle *bundle = nil;

- (id)init
{
self = [super init];

defaults = [NSUserDefaults standardUserDefaults];
domain = [[defaults persistentDomainForName:NSGlobalDomain] mutableCopy];

bundle = [NSBundle bundleForClass:[self class]];
NSString *imagePath = [bundle pathForResource:@"Services" ofType:@"tiff"];
image = [[NSImage alloc] initWithContentsOfFile:imagePath];
Expand All @@ -55,7 +42,6 @@ - (id)init

- (void)dealloc
{
NSLog(@"Services -dealloc");
[image release];
[super dealloc];
}
Expand All @@ -64,19 +50,22 @@ - (void)awakeFromNib
{
[view retain];
[window release];

serviceManager = [GSServicesManager manager];
[serviceManager rebuildServices];
NSLog(@"Services: %@", [[serviceManager menuServices] allKeys]);
[servicesList loadColumnZero];
}

- (NSView *)view
{
if (view == nil)
{
if (![NSBundle loadNibNamed:@"Services" owner:self])
{
NSLog (@"Services.preferences: Could not load NIB, aborting.");
return nil;
}
if (view == nil) {
if (![NSBundle loadNibNamed:@"Services" owner:self]) {
NSLog(@"Services.preferences: Could not load NIB, aborting.");
return nil;
}

}

return view;
}

Expand All @@ -93,6 +82,44 @@ - (NSImage *)buttonImage
//
// Action methods
//
- (void)setServiceState:(id)sender
{
}

- (void)browser:(NSBrowser *)brow
willDisplayCell:(NSBrowserCell *)cell
atRow:(NSInteger)row
column:(NSInteger)col
{
NSDictionary *services = [serviceManager menuServices];

if (col == 0) {
NSArray *apps = [services allKeys];
NSString *app = [apps objectAtIndex:row];

// [cell setRepresentedObject:app];
[cell setLeaf:NO];
[cell setStringValue:app];
} else {
// NSArray *ls = [[brow selectedCellInColumn:0] representedObject];
// id it = [ls objectAtIndex:row];
// NSString *name = [it valueForKeyPath:@"NSMenuItem.default"];
// [cell setLeaf:YES];
// [cell setStringValue:niceName(name)];
// [cell setRepresentedObject:name];
}
}

- (NSInteger)browser:(NSBrowser *)brow numberOfRowsInColumn:(NSInteger)col
{
if (col == 0) {
return [[[serviceManager menuServices] allKeys] count];
} else {
// NSArray *ls = [[brow selectedCellInColumn:0] representedObject];
// return [ls count];
return 0;
}
}

@end

0 comments on commit 7bd54a8

Please sign in to comment.