source: trunk/third/mozilla/xpfe/bootstrap/nsNativeAppSupportGtk.cpp @ 19518

Revision 19518, 3.5 KB checked in by rbasch, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19517, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * The contents of this file are subject to the Mozilla Public
4 * License Version 1.1 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of
6 * the License at http://www.mozilla.org/MPL/
7 *
8 * Software distributed under the License is distributed on an "AS
9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 * implied. See the License for the specific language governing
11 * rights and limitations under the License.
12 *
13 * The Original Code is the Mozilla browser.
14 *
15 * The Initial Developer of the Original Code is Netscape
16 * Communications Corporation. Portions created by Netscape are
17 * Copyright (C) 1999 Netscape Communications Corporation. All
18 * Rights Reserved.
19 *
20 * Contributor(s):
21 * syd@netscape.com 2/12/00.
22 * pavlov@netscape.com 2/13/00.
23 * bryner@netscape.com 11/20/01.
24 */
25
26#include "nsNativeAppSupportBase.h"
27#include "gdk/gdk.h"
28#include "prenv.h"
29#include "nsString.h"
30#ifdef MOZ_XUL_APP
31extern char* splash_xpm[];
32#else
33#include SPLASH_XPM
34#endif
35
36class nsSplashScreenGtk : public nsISplashScreen {
37public:
38  nsSplashScreenGtk();
39  virtual ~nsSplashScreenGtk();
40
41  NS_IMETHOD Show();
42  NS_IMETHOD Hide();
43
44  NS_DECL_ISUPPORTS
45
46private:
47  GdkWindow *mDialog;
48}; // class nsSplashScreenGtk
49
50class nsNativeAppSupportGtk : public nsNativeAppSupportBase {
51  // We don't have any methods to override.
52};
53
54NS_IMPL_ISUPPORTS1(nsSplashScreenGtk, nsISplashScreen)
55
56nsSplashScreenGtk::nsSplashScreenGtk()
57{
58}
59
60nsSplashScreenGtk::~nsSplashScreenGtk()
61{
62  Hide();
63}
64
65NS_IMETHODIMP nsSplashScreenGtk::Show()
66{
67#ifdef MOZ_XUL_APP
68  if (!splash_xpm[0])
69    return NS_OK;
70#endif
71
72  nsCAutoString path(PR_GetEnv("MOZILLA_FIVE_HOME"));
73
74  if (path.IsEmpty()) {
75    path.Assign("splash.xpm");
76  } else {
77    path.Append("/splash.xpm");
78  }
79
80  /* See if the user has a custom splash screen */
81  GdkPixmap* pmap = gdk_pixmap_colormap_create_from_xpm(NULL,
82                                                    gdk_colormap_get_system(),
83                                                    NULL, NULL, path.get());
84
85  if (!pmap) {
86    /* create a pixmap based on xpm data */
87    pmap = gdk_pixmap_colormap_create_from_xpm_d(NULL,
88                                                    gdk_colormap_get_system(),
89                                                    NULL, NULL, splash_xpm);
90  }
91
92  if (!pmap) {
93    gdk_window_destroy(mDialog);
94    mDialog = nsnull;
95    return NS_ERROR_FAILURE;
96  }
97
98  gint width, height;
99  gdk_window_get_size(pmap, &width, &height);
100
101  GdkWindowAttr attr;
102  attr.window_type = GDK_WINDOW_TEMP;
103  attr.wclass = GDK_INPUT_OUTPUT;
104  attr.x = (gdk_screen_width() >> 1) - (width >> 1);
105  attr.y = (gdk_screen_height() >> 1) - (height >> 1);
106  attr.width = width;
107  attr.height = height;
108  attr.event_mask = 0;
109  mDialog = gdk_window_new(NULL, &attr, GDK_WA_X | GDK_WA_Y);
110
111  gdk_window_set_back_pixmap(mDialog, pmap, FALSE);
112  gdk_pixmap_unref(pmap);
113
114  gdk_window_show(mDialog);
115
116  return NS_OK;
117}
118
119NS_IMETHODIMP nsSplashScreenGtk::Hide()
120{
121  if (mDialog) {
122    gdk_window_destroy(mDialog);
123    mDialog = nsnull;
124  }
125  return NS_OK;
126}
127
128nsresult NS_CreateNativeAppSupport(nsINativeAppSupport** aNativeApp) {
129  *aNativeApp = new nsNativeAppSupportGtk;
130  NS_ADDREF(*aNativeApp);
131  return NS_OK;
132}
133
134nsresult NS_CreateSplashScreen(nsISplashScreen** aSplash) {
135  *aSplash = new nsSplashScreenGtk;
136  NS_ADDREF(*aSplash);
137  return NS_OK;
138}
139
140PRBool NS_CanRun()
141{
142  return PR_TRUE;
143}
Note: See TracBrowser for help on using the repository browser.