~ubuntu-branches/ubuntu/trusty/blam/trusty

« back to all changes in this revision

Viewing changes to src/ItemView.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-03-14 14:57:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060314145731-8ksmc4mhwzk3bn1j
Tags: 1.8.2+cvs20060124-0ubuntu1
* New CVS snapshot
* egg-sharp.diff:
  + Fix the TrayIcon breakage by replacing it with generic TrayIcon
    implementation used by banshee, beagle, etc
* firefox.diff:
  + Fix build with firefox 1.5
    (Closes: Malone #4839, #5354, #5876, #32758, #34368, #34581)
* gtk-sharp2.diff:
  + Build with Gtk#2

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
using System;
11
11
using GtkSharp;
12
12
using Gecko;
13
 
using Mono.Posix;
 
13
using Mono.Unix;
14
14
using System.Collections;
15
15
using System.Reflection;
16
16
using System.IO;
85
85
        {
86
86
            System.Console.WriteLine ("Net stop");
87
87
        }
88
 
        
89
 
        private void Load()
 
88
 
 
89
        private void Load()
90
90
        {
91
 
 
92
 
 
93
 
            mMoz.OpenStream ("file://" + Defines.APP_DATADIR + "/images/",
94
 
                             "text/html");
95
 
            mMoz.AppendData (HtmlHeader());
96
 
 
97
 
            if (currentItem.Text.Length > 0) {
98
 
                mMoz.AppendData ("<table cellpadding=\"2\"><tr><td>");
99
 
                mMoz.AppendData (EncodeUnicode(FixMarkup(currentItem.Text)));
100
 
                mMoz.AppendData ("</td></tr></table>");
101
 
            }
102
 
 
103
 
            mMoz.AppendData (HtmlFooter());
 
91
                        Theme theme = Application.TheApp.ThemeManager.CurrentTheme;
 
92
 
 
93
            string author  = (!"".Equals(currentItem.Author)) ? String.Format(Catalog.GetString("by {0}"), currentItem.Author) : "&nbsp;";
 
94
            string link    = Catalog.GetString("Show in browser");
 
95
            string pubdate = (!currentItem.PubDate.Equals(DateTime.MinValue)) ? currentItem.PubDate.ToLongDateString() : "&nbsp;";
 
96
            string text    = HtmlUtils.EncodeUnicode(HtmlUtils.FixMarkup(currentItem.Text));
 
97
            string title   = HtmlUtils.Escape(currentItem.Title);
 
98
            string url     = currentItem.Link;
 
99
 
 
100
                        mMoz.OpenStream ("file://" + theme.Path + "/", "text/html");
 
101
            mMoz.AppendData (theme.Render(author, link, pubdate, 
 
102
                                                                                  text, title, url));
104
103
            mMoz.CloseStream ();
105
104
        }
106
105
 
116
115
            args.RetVal = true;
117
116
        }
118
117
 
119
 
        private static string EncodeUnicode(string str)
120
 
        {
121
 
            StringBuilder output = new StringBuilder();
122
 
 
123
 
            foreach (char c in str) {
124
 
                if ((int)c > 128) {
125
 
                    output.Append("&#");
126
 
                    output.Append(((int)c).ToString());
127
 
                    output.Append(";");
128
 
                } else {
129
 
                    output.Append(c);
130
 
                }
131
 
            }
132
 
 
133
 
            return output.ToString();
134
 
        }
135
 
 
136
 
        private string HtmlBox (string leftContent, string rightContent)
137
 
        {
138
 
            string html = "<table bgcolor=\"#333333\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">" +
139
 
                "  <tr>" +
140
 
                "    <td bgcolor=\"#ffffff\">" +
141
 
                "      <img src=\"blam-box-top-left.png\">" +
142
 
                "    </td>" +
143
 
                "    <td colspan=2 width=\"100%\">" +
144
 
                "      <img src=\"blam-box-pad.png\">" +
145
 
                "    </td>" +
146
 
                "    <td bgcolor=\"#ffffff\">" +
147
 
                "      <img src=\"blam-box-top-right.png\">" +
148
 
                "    </td>" +
149
 
                "  </tr>" +
150
 
                "  <tr>" +
151
 
                "    <td>" +
152
 
                "      <img src=\"blam-box-pad.png\">" +
153
 
                "    </td>" +
154
 
                "    <td width=\"75%\" valign=\"top\">" +
155
 
                leftContent +
156
 
                "    </td>" +
157
 
                "    <td align=\"right\" valign=\"top\">" +
158
 
                rightContent +
159
 
                "    </td>" +
160
 
                "    <td>" +
161
 
                "      <img src=\"blam-box-pad.png\">" +
162
 
                "    </td>" +
163
 
                "  </tr>" +
164
 
                "  <tr>" +
165
 
                "    <td bgcolor=\"#ffffff\">" +
166
 
                "      <img src=\"blam-box-bottom-left.png\">" +
167
 
                "    </td>" +
168
 
                "    <td colspan=2 width=\"100%\">" +
169
 
                "      <img src=\"blam-box-pad.png\">" +
170
 
                "    </td>" +
171
 
                "    <td bgcolor=\"#ffffff\">" +
172
 
                "      <img src=\"blam-box-bottom-right.png\">" +
173
 
                "    </td>" +
174
 
                "  </tr>" +
175
 
                "</table>";
176
 
            
177
 
            return html;
178
 
        }
179
 
 
180
 
        private string HtmlHeader ()
181
 
        {
182
 
            string date = "";
183
 
            string title;
184
 
            StringBuilder html;
185
 
 
186
 
            html = new StringBuilder ();
187
 
            // Don't print the date if it's not set (avoid showing 0001 Jan 01)
188
 
            // in the item header.
189
 
            
190
 
            html.Append ("<html>" +
191
 
                         "  <head>" +
192
 
                         "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
193
 
                         "    <title>" + HtmlUtils.Escape(currentItem.Title) + "</title>"+
194
 
                         "  </head>" +
195
 
                         "  <body>");
196
 
            
197
 
            if (!currentItem.PubDate.Equals (DateTime.MinValue)) {
198
 
                date = "<font color=\"#ffffff\" size=\"+1\">" +
199
 
                    currentItem.PubDate.ToString ("d MMM yyyy") +
200
 
                    "</font>";
201
 
            } else {
202
 
                date = "&nbsp;";
203
 
            }
204
 
            
205
 
            title = "<font color=\"#ffffff\" size=\"+1\">" +
206
 
                HtmlUtils.Escape(currentItem.Title) +
207
 
                "</font>";
208
 
 
209
 
            html.Append (HtmlBox (title, date));
210
 
            return html.ToString ();
211
 
        }
212
 
 
213
 
        private string HtmlFooter()
214
 
        {
215
 
            StringBuilder str = new StringBuilder();
216
 
            string link = "";
217
 
            string author;
218
 
 
219
 
            if (currentItem.Link != null && currentItem.Link.Equals ("") != true) {
220
 
                link = String.Format("<a href=\"{0}\">" +
221
 
                                     "<font color=\"#ffff00\">" +
222
 
                                     Catalog.GetString ("Show in browser") +
223
 
                                     "</font></a>",
224
 
                                     currentItem.Link);
225
 
            }
226
 
 
227
 
            if (currentItem.Author != null && currentItem.Author != "") {
228
 
                string authorStr = String.Format (Catalog.GetString ("by {0}"), currentItem.Author);
229
 
                
230
 
                author = "<font color=\"#aaaaaa\">" + authorStr + "</font>";
231
 
            } else {
232
 
                author = "&nbsp;";
233
 
            }
234
 
 
235
 
            str.Append("<br><br>");
236
 
            str.Append(HtmlBox(link, author));
237
 
            str.Append("</body></html>");
238
 
 
239
 
            return str.ToString();
240
 
        }
241
 
 
242
 
        private string FixMarkup(string str)
243
 
        {
244
 
            string tStr = str.Trim().Replace("</p>", "").Replace("</P>", "");
245
 
 
246
 
            if (!tStr.StartsWith("<p>") && !tStr.StartsWith("<P>")) {
247
 
                tStr = "<br/><br/>" + tStr;
248
 
            }
249
 
 
250
 
            return tStr.Replace("<p>", "<br/><br/>").Replace("<P>", "<br/><br/>");
251
 
        }
252
 
 
253
118
        private void SetFonts ()
254
119
        {
255
120
            string varFont = Conf.Get (Preference.VARIABLE_FONT, "Sans 12");