NetSurf
about.c
Go to the documentation of this file.
1 /*
2  * Copyright 2013 Ole Loots <ole@monochrom.net>
3  *
4  * This file is part of NetSurf, http://www.netsurf-browser.org/
5  *
6  * NetSurf is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * NetSurf is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include <limits.h>
20 #include <unistd.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <stdbool.h>
24 #include <stdint.h>
25 
26 #include "testament.h"
27 #include "utils/useragent.h"
28 #include "utils/nsurl.h"
29 #include "utils/messages.h"
30 #include "desktop/version.h"
31 #include "netsurf/browser_window.h"
32 
33 #include "curl/curlver.h"
34 
35 #include "cflib.h"
36 #include "atari/gui.h"
37 #include "atari/misc.h"
38 #include "atari/plot/plot.h"
39 #include "atari/gemtk/gemtk.h"
40 #include "atari/res/netsurf.rsh"
41 #include "atari/about.h"
42 
43 static OBJECT * about_form = NULL;
44 static char * infocontent;
45 static char version[32];
46 VdiHdl vdihandle;
47 
48 static short __CDECL about_userdraw(PARMBLK *parmblock)
49 {
50  short pxy[8];
51  short dummy;
52  short cheight = 8, cwidth = gl_wchar;
53  char c[2] = {0,0};
54 
55  /* Setup area to the full area...: */
56  GRECT area = {
57  .g_x = parmblock->pb_x,
58  .g_y = parmblock->pb_y,
59  .g_w = parmblock->pb_w-8,
60  .g_h = parmblock->pb_h
61  };
62 
63  /* Setup clip: */
64  GRECT clip = {
65  .g_x = parmblock->pb_xc,
66  .g_y = parmblock->pb_yc,
67  .g_w = parmblock->pb_wc,
68  .g_h = parmblock->pb_hc
69  };
70 
71  if(parmblock->pb_currstate == parmblock->pb_prevstate){
72  short cur_x, cur_y;
73  char *content;
74  int content_len;
75 
76  content = (char*)parmblock->pb_parm;
77  content_len = strlen(content);
78  cur_x = area.g_x;
79  cur_y = area.g_y;
80 
81 
82  if(!rc_intersect(&area, &clip)){
83  return (0);
84  }
85 
86  pxy[0] = clip.g_x;
87  pxy[1] = clip.g_y;
88  pxy[2] = pxy[0] + clip.g_w-1;
89  pxy[3] = pxy[1] + clip.g_h-1;
90  vs_clip(vdihandle, 1, pxy);
91  vst_alignment(vdihandle, 0, 5, &dummy, &dummy);
92  vst_height(vdihandle, sys_sml_height, &dummy, &dummy, &dummy, &cheight);
93  vswr_mode(vdihandle, 2);
94 
95  for (int i=0; i<content_len; i++) {
96  if (content[i] == '\n') {
97  cur_y += cheight;
98  cur_x = area.g_x;
99  } else {
100  if (cur_x >= clip.g_x
101  && cur_x < (clip.g_x + clip.g_w)
102  && cur_y > clip.g_y
103  && cur_y < (clip.g_w + clip.g_h)) {
104  c[0] = content[i];
105  v_gtext(vdihandle, cur_x, cur_y, c);
106  }
107  cur_x += cwidth;
108  }
109  }
110 
111  vs_clip(vdihandle, 0, pxy);
112  }
113  return(0);
114 }
115 
117 {
118  static USERBLK userblk;
119  short elem = 0;
120  const char * goto_url = NULL;
121  nserror nserr;
122  nsurl *url;
123 
125 
126  infocontent = malloc(8000);
127  memset(infocontent, 0, 8000);
128 
129  snprintf(infocontent, 8000,
130  "Netsurf : %s\n"
131  "Build ID : %s\n"
132  "Date : %s\n"
133  "MiNTLib : %d.%d-%d%s\n"
134  "GEMLib : %d.%d-%d%s\n"
135  "CFLib : %d.%d-%d%s\n"
136  "cURL : %s\n",
138  WT_REVID,
139  WT_COMPILEDATE,
140  __MINTLIB_MAJOR__, __MINTLIB_MINOR__, __MINTLIB_REVISION__,
141  __MINTLIB_BETATAG__,
142  __GEMLIB_MAJOR__, __GEMLIB_MINOR__, __GEMLIB_REVISION__,
143  __GEMLIB_BETATAG__,
144  __CFLIB_MAJOR__, __CFLIB_MINOR__, __CFLIB_REVISION__,
145  __CFLIB_BETATAG__,
146  LIBCURL_VERSION);
147 
148  about_form = gemtk_obj_get_tree(ABOUT);
149  snprintf(version, 32, "%s%s", "NetSurf ", (char*)netsurf_version);
150  set_string(about_form, ABOUT_LBL_VERSION, version);
151 
152  userblk.ub_code = about_userdraw;
153  userblk.ub_parm = (long) infocontent;
154  about_form[ABOUT_CONTENT].ob_spec.userblk = &userblk;
155 
156  elem = simple_dial(about_form, 0);
157  switch (elem) {
158  case ABOUT_CREDITS:
159  goto_url = "about:credits";
160  break;
161 
162  case ABOUT_LICENSE:
163  goto_url = "about:licence";
164  break;
165  };
166 
167  free(infocontent);
168 
169  if (goto_url != NULL) {
170  nserr = nsurl_create(goto_url, &url);
171  if (nserr == NSERROR_OK) {
173  url,
174  NULL,
175  NULL,
176  NULL);
177  nsurl_unref(url);
178  }
179  if (nserr != NSERROR_OK) {
181  }
182  }
183 /*
184  dlg = open_mdial(about_form, 0);
185  do {
186  elem = do_mdial(dlg);
187  printf ("elem: %d\n", elem);
188  switch (elem) {
189  case ABOUT_OK:
190  close_dlg = true;
191  break;
192 
193  case ABOUT_CREDITS:
194  close_dlg = true;
195  break;
196 
197  case ABOUT_LICENSE:
198  close_dlg = true;
199  break;
200  }
201  } while (close_dlg == false);
202 
203  close_mdial(dlg);
204 */
205 
206 }
Interface to utility string handling.
nserror atari_warn_user(const char *warning, const char *detail)
Warn the user of an event.
Definition: misc.c:56
Localised message support (interface).
VdiHdl plot_get_vdi_handle(void)
Definition: plot.c:1918
void atari_about_show(void)
Definition: about.c:116
nserror
Enumeration of error codes.
Definition: errors.h:29
static char version[32]
Definition: about.c:45
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
Content which corresponds to a single URL.
No error.
Definition: errors.h:30
const char *const netsurf_version
User friendly version string.
Definition: gui_menu.c:92
VdiHdl vdihandle
Definition: about.c:46
this will form a new history node (don&#39;t set for back/reload/etc)
static short __CDECL about_userdraw(PARMBLK *parmblock)
Definition: about.c:48
Version information interface.
const char * user_agent_string(void)
Retrieve the core user agent for this release.
Definition: useragent.c:74
Browser window creation and manipulation interface.
static char * infocontent
Definition: about.c:44
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
static OBJECT * about_form
Definition: about.c:43
NetSurf URL handling (interface).
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.