Procházet zdrojové kódy

DCC Plugin now uses its own icons. Fixes issue 1253.

URL Builder now supports plugin:// URLs. Fixes issue 1252.

git-svn-id: http://svn.dmdirc.com/trunk@4077 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith před 16 roky
rodič
revize
cb1d3b464b

+ 3
- 1
src/com/dmdirc/addons/dcc/DCCChatWindow.java Zobrazit soubor

52
 	 * @param targetNick Nickname of target
52
 	 * @param targetNick Nickname of target
53
 	 */
53
 	 */
54
 	public DCCChatWindow(final DCCPlugin plugin, final DCCChat dcc, final String title, final String nick, final String targetNick) {
54
 	public DCCChatWindow(final DCCPlugin plugin, final DCCChat dcc, final String title, final String nick, final String targetNick) {
55
-		super(plugin, title, false);
55
+		super(plugin, title, "dcc-chat-inactive", false);
56
 		this.dcc = dcc;
56
 		this.dcc = dcc;
57
 		dcc.setHandler(this);
57
 		dcc.setHandler(this);
58
 		nickname = nick;
58
 		nickname = nick;
115
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
115
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
116
 		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETCLOSED, buff, this);
116
 		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETCLOSED, buff, this);
117
 		addLine(buff, "Socket closed");
117
 		addLine(buff, "Socket closed");
118
+        setIcon("dcc-chat-inactive");
118
 	}
119
 	}
119
 	
120
 	
120
 	/**
121
 	/**
127
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
128
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
128
 		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETOPENED, buff, this);
129
 		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETOPENED, buff, this);
129
 		addLine(buff, "Socket opened");
130
 		addLine(buff, "Socket opened");
131
+        setIcon("dcc-chat-active");
130
 	}
132
 	}
131
 	
133
 	
132
 	/**
134
 	/**

+ 7
- 4
src/com/dmdirc/addons/dcc/DCCFrame.java Zobrazit soubor

157
 	 *
157
 	 *
158
 	 * @param plugin The DCCPlugin that owns this frame
158
 	 * @param plugin The DCCPlugin that owns this frame
159
 	 * @param title The title of this window
159
 	 * @param title The title of this window
160
+     * @param icon The icon to use
160
 	 */
161
 	 */
161
-	public DCCFrame(final DCCPlugin plugin, final String title) {
162
-		this(plugin, title, true);
162
+	public DCCFrame(final DCCPlugin plugin, final String title, final String icon) {
163
+		this(plugin, title, icon, true);
163
 	}
164
 	}
164
 	
165
 	
165
 	/**
166
 	/**
168
 	 * @param plugin The DCCPlugin that owns this frame
169
 	 * @param plugin The DCCPlugin that owns this frame
169
 	 * @param title The title of this window
170
 	 * @param title The title of this window
170
 	 * @param defaultWindow Create default (empty) window.
171
 	 * @param defaultWindow Create default (empty) window.
172
+     * @param icon The icon to use
171
 	 */
173
 	 */
172
-	public DCCFrame(final DCCPlugin plugin, final String title, final boolean defaultWindow) {
173
-		super("raw", IdentityManager.getGlobalConfig());
174
+	public DCCFrame(final DCCPlugin plugin, final String title,
175
+            final String icon ,final boolean defaultWindow) {
176
+		super(icon, IdentityManager.getGlobalConfig());
174
 		this.title = title;
177
 		this.title = title;
175
 		this.plugin = plugin;
178
 		this.plugin = plugin;
176
 
179
 

+ 10
- 1
src/com/dmdirc/addons/dcc/DCCPlugin.java Zobrazit soubor

358
 	 * Create the container window.
358
 	 * Create the container window.
359
 	 */
359
 	 */
360
 	protected void createContainer() {
360
 	protected void createContainer() {
361
-		container = new DCCFrame(this, "DCCs"){};
361
+		container = new DCCFrame(this, "DCCs", "dcc"){};
362
 		final TextLabel label = new TextLabel("This is a placeholder window to group DCCs together.");
362
 		final TextLabel label = new TextLabel("This is a placeholder window to group DCCs together.");
363
 		label.setText(label.getText()+"\n\nClosing this window will close all the active DCCs");
363
 		label.setText(label.getText()+"\n\nClosing this window will close all the active DCCs");
364
 		((TextFrame)container.getFrame()).getContentPane().add(label);
364
 		((TextFrame)container.getFrame()).getContentPane().add(label);
415
 		defaults.setOption(MY_DOMAIN, "send.blocksize", "1024");
415
 		defaults.setOption(MY_DOMAIN, "send.blocksize", "1024");
416
 		defaults.setOption(MY_DOMAIN, "receive.autoaccept", "false");
416
 		defaults.setOption(MY_DOMAIN, "receive.autoaccept", "false");
417
 		defaults.setOption(MY_DOMAIN, "general.ip", "");
417
 		defaults.setOption(MY_DOMAIN, "general.ip", "");
418
+        
419
+        final String url = "plugin://dcc:com/dmdirc/addons/dcc/res/";
420
+        defaults.setOption("icon", "dcc", url + "transfers.png");
421
+        defaults.setOption("icon", "dcc-chat-active", url + "chat.png");
422
+        defaults.setOption("icon", "dcc-chat-inactive", url + "chat-inactive.png");
423
+        defaults.setOption("icon", "dcc-send-active", url + "send.png");
424
+        defaults.setOption("icon", "dcc-send-inactive", url + "send-inactive.png");
425
+        defaults.setOption("icon", "dcc-receive-active", url + "receive.png");
426
+        defaults.setOption("icon", "dcc-receive-inactive", url + "receive-inactive.png");
418
 		
427
 		
419
 		defaults.setOption("formatter", "DCCChatStarting", "Starting DCC Chat with: %1$s on %2$s:%3$s");
428
 		defaults.setOption("formatter", "DCCChatStarting", "Starting DCC Chat with: %1$s on %2$s:%3$s");
420
 		defaults.setOption("formatter", "DCCChatInfo", "%1$s");
429
 		defaults.setOption("formatter", "DCCChatInfo", "%1$s");

+ 6
- 1
src/com/dmdirc/addons/dcc/DCCSendWindow.java Zobrazit soubor

88
 	 * @param targetNick Nickname of target
88
 	 * @param targetNick Nickname of target
89
 	 */
89
 	 */
90
 	public DCCSendWindow(final DCCPlugin plugin, final DCCSend dcc, final String title, final String nick, final String targetNick) {
90
 	public DCCSendWindow(final DCCPlugin plugin, final DCCSend dcc, final String title, final String nick, final String targetNick) {
91
-		super(plugin, title);
91
+		super(plugin, title, dcc.getType() == DCCSend.TransferType.SEND ? 
92
+            "dcc-send-inactive" : "dcc-receive-inactive");
92
 		this.dcc = dcc;
93
 		this.dcc = dcc;
93
 		dcc.setHandler(this);
94
 		dcc.setHandler(this);
94
 		nickname = nick;
95
 		nickname = nick;
216
 			status.setText("Status: Transfer Failed.");
217
 			status.setText("Status: Transfer Failed.");
217
 		}
218
 		}
218
 		updateSpeedAndTime();
219
 		updateSpeedAndTime();
220
+        setIcon(dcc.getType() == DCCSend.TransferType.SEND ? 
221
+            "dcc-send-active" : "dcc-receive-active");
219
 	}
222
 	}
220
 	
223
 	
221
 	/**
224
 	/**
228
 		ActionManager.processEvent(DCCActions.DCC_SEND_SOCKETOPENED, null, this);
231
 		ActionManager.processEvent(DCCActions.DCC_SEND_SOCKETOPENED, null, this);
229
 		status.setText("Status: Socket Opened");
232
 		status.setText("Status: Socket Opened");
230
 		timeStarted = System.currentTimeMillis();
233
 		timeStarted = System.currentTimeMillis();
234
+        setIcon(dcc.getType() == DCCSend.TransferType.SEND ? 
235
+            "dcc-send-inactive" : "dcc-receive-inactive");
231
 	}
236
 	}
232
 	
237
 	
233
 	/**
238
 	/**

+ 24
- 0
src/com/dmdirc/util/URLBuilder.java Zobrazit soubor

24
 
24
 
25
 import com.dmdirc.logger.ErrorLevel;
25
 import com.dmdirc.logger.ErrorLevel;
26
 import com.dmdirc.logger.Logger;
26
 import com.dmdirc.logger.Logger;
27
+import com.dmdirc.plugins.PluginManager;
27
 import com.dmdirc.ui.themes.ThemeManager;
28
 import com.dmdirc.ui.themes.ThemeManager;
28
 
29
 
29
 import java.net.MalformedURLException;
30
 import java.net.MalformedURLException;
98
         return buildJarURL(ThemeManager.getThemeDirectory() + theme + ".zip", path);
99
         return buildJarURL(ThemeManager.getThemeDirectory() + theme + ".zip", path);
99
     }
100
     }
100
     
101
     
102
+    /**
103
+     * Builds an URL pointing to a resource within a DMDirc plugin.
104
+     * 
105
+     * @param plugin The plugin which the resource is located in
106
+     * @param path The path within the theme of the resource
107
+     * @return An URL corresponding to the specified resource, or null on failure
108
+     */
109
+    public static URL buildPluginURL(final String plugin, final String path) {
110
+        return buildJarURL(
111
+                PluginManager.getPluginManager().getPluginInfoByName(plugin).getFullFilename(),
112
+                path);
113
+    }
114
+    
101
     /**
115
     /**
102
      * Constructs an URL corresponding to the described resource.
116
      * Constructs an URL corresponding to the described resource.
103
      * 
117
      * 
106
      * <li>jar://path/to/jarfile:path/inside/jarfile
120
      * <li>jar://path/to/jarfile:path/inside/jarfile
107
      * <li>zip://path/to/zipfile:path/inside/zipfile
121
      * <li>zip://path/to/zipfile:path/inside/zipfile
108
      * <li>theme://theme_name:file/inside/theme
122
      * <li>theme://theme_name:file/inside/theme
123
+     * <li>plugin://plugin_name:file/inside/plugin
109
      * <li>http://server/path
124
      * <li>http://server/path
110
      * <li>https://server/path
125
      * <li>https://server/path
111
      * <li>[file://]/path/on/filesystem</ul>
126
      * <li>[file://]/path/on/filesystem</ul>
124
             } else {
139
             } else {
125
                 return buildJarURL(spec.substring(6, offset), spec.substring(offset + 1));
140
                 return buildJarURL(spec.substring(6, offset), spec.substring(offset + 1));
126
             }
141
             }
142
+        } else if (spec.startsWith("plugin://")) {
143
+            final int offset = spec.indexOf(':', 8);
144
+            
145
+            if (offset < 0) {
146
+                Logger.userError(ErrorLevel.LOW, "Invalid URL, must contain ':': " + spec);
147
+                return null;
148
+            } else {
149
+                return buildPluginURL(spec.substring(9, offset), spec.substring(offset + 1));
150
+            }            
127
         } else if (spec.startsWith("theme://")) {
151
         } else if (spec.startsWith("theme://")) {
128
             final int offset = spec.indexOf(':', 8);
152
             final int offset = spec.indexOf(':', 8);
129
             
153
             

Načítá se…
Zrušit
Uložit