зеркало из https://github.com/mozilla/pjs.git
being implimenting the use of CmdLineService, add internal gtk refcounting
measures (not complete), and remove some excess code.
This commit is contained in:
Родитель
8084f5dd4a
Коммит
a017814cb7
|
@ -23,12 +23,16 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsSelectionMgr.h"
|
||||
#include "nsXPComCIID.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
|
||||
static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kICmdLineServiceIID, NS_ICOMMANDLINE_SERVICE_IID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell constructor
|
||||
|
@ -80,16 +84,34 @@ static void event_processor_callback(gpointer data,
|
|||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsAppShell::Create(int* argc, char ** argv)
|
||||
#ifdef CMDLINEARGS
|
||||
NS_METHOD nsAppShell::Create(int *bac, char **bav)
|
||||
#else
|
||||
NS_METHOD nsAppShell::Create(int *argc, char **argv)
|
||||
#endif
|
||||
|
||||
{
|
||||
gchar *path;
|
||||
|
||||
#ifdef CMDLINEARGS
|
||||
int *argc;
|
||||
char **argv;
|
||||
nsICmdLineService *cmdLineArgs=nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = nsServiceManager::GetService(kCmdLineServiceCID,
|
||||
kICmdLineServiceIID,
|
||||
(nsISupports **)&cmdLineArgs);
|
||||
// Get the value of -width option
|
||||
rv = cmdLineArgs->GetArgc(argc);
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
#endif
|
||||
gtk_set_locale ();
|
||||
|
||||
gtk_init (argc, &argv);
|
||||
|
||||
// delete the cmdLineArgs thing?
|
||||
|
||||
gdk_rgb_init();
|
||||
gdk_rgb_set_verbose(PR_TRUE);
|
||||
|
||||
path = g_strdup_printf("%s%s", g_get_home_dir(),"/.gtkrc");
|
||||
gtk_rc_parse(path);
|
||||
|
@ -176,6 +198,9 @@ NS_METHOD nsAppShell::Exit()
|
|||
void* nsAppShell::GetNativeData(PRUint32 aDataType)
|
||||
{
|
||||
if (aDataType == NS_NATIVE_SHELL) {
|
||||
// this isn't accually used, but if it was, we need to gtk_widget_ref() it.
|
||||
|
||||
|
||||
// return mTopLevel;
|
||||
}
|
||||
return nsnull;
|
||||
|
|
|
@ -708,6 +708,9 @@ void handle_scrollbar_value_changed(GtkAdjustment *adj, gpointer p)
|
|||
|
||||
GdkWindow *win = (GdkWindow *)widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
gdk_window_get_pointer(win, &sevent.point.x, &sevent.point.y, nsnull);
|
||||
#ifdef NS_GTK_REF
|
||||
gdk_window_unref(win);
|
||||
#endif
|
||||
|
||||
widget->OnScroll(sevent, adj->value);
|
||||
|
||||
|
|
|
@ -161,15 +161,6 @@ PRInt32 nsListBox::GetItemCount()
|
|||
PRBool nsListBox::RemoveItemAt(PRInt32 aPosition)
|
||||
{
|
||||
gtk_clist_remove(GTK_CLIST(mCList), aPosition);
|
||||
/*
|
||||
int count = 0;
|
||||
XtVaGetValues(mCList, XmNitemCount, &count, nsnull);
|
||||
if (aPosition >= 0 && aPosition < count) {
|
||||
XmListDeletePos(mCList, aPosition+1);
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
*/
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -190,24 +181,6 @@ PRBool nsListBox::GetItemAt(nsString& anItem, PRInt32 aPosition)
|
|||
result = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
|
||||
#if 0
|
||||
XmStringTable list;
|
||||
|
||||
int count = 0;
|
||||
XtVaGetValues(mCList, XmNitems, &list, XmNitemCount, &count, nsnull);
|
||||
|
||||
if (aPosition >= 0 && aPosition < count) {
|
||||
char * text;
|
||||
if (XmStringGetLtoR(list[aPosition], XmFONTLIST_DEFAULT_TAG, &text)) {
|
||||
anItem.SetLength(0);
|
||||
anItem.Append(text);
|
||||
XtFree(text);
|
||||
result = PR_TRUE;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -267,13 +240,6 @@ PRInt32 nsListBox::GetSelectedIndex()
|
|||
NS_METHOD nsListBox::SelectItem(PRInt32 aPosition)
|
||||
{
|
||||
gtk_clist_select_row(GTK_CLIST(mCList), aPosition, 0);
|
||||
/*
|
||||
int count = 0;
|
||||
XtVaGetValues(mCList, XmNitemCount, &count, nsnull);
|
||||
if (aPosition >= 0 && aPosition < count) {
|
||||
XmListSelectPos(mCList, aPosition+1, PR_FALSE);
|
||||
}
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -284,7 +250,10 @@ NS_METHOD nsListBox::SelectItem(PRInt32 aPosition)
|
|||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetSelectedCount()
|
||||
{
|
||||
return (PRInt32)g_list_length(GTK_CLIST(mCList)->selection);
|
||||
if (!GTK_CLIST(mCList)->selection)
|
||||
return 0;
|
||||
else
|
||||
return (PRInt32)g_list_length(GTK_CLIST(mCList)->selection);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -330,7 +299,6 @@ NS_METHOD nsListBox::SetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize)
|
|||
NS_METHOD nsListBox::Deselect()
|
||||
{
|
||||
gtk_clist_unselect_all(GTK_CLIST(mCList));
|
||||
// XtVaSetValues(mCList, XmNselectedItemCount, 0, NULL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ void nsToolkit::CreateSharedGC(void)
|
|||
|
||||
GdkGC *nsToolkit::GetSharedGC(void)
|
||||
{
|
||||
mSharedGC = gdk_gc_ref(mSharedGC);
|
||||
return mSharedGC;
|
||||
}
|
||||
|
||||
|
|
|
@ -529,12 +529,21 @@ void *nsWidget::GetNativeData(PRUint32 aDataType)
|
|||
{
|
||||
switch(aDataType) {
|
||||
case NS_NATIVE_WINDOW:
|
||||
#ifdef NS_GTK_REF
|
||||
return (void *)gdk_window_ref(mWidget->window);
|
||||
#else
|
||||
return (void *)mWidget->window;
|
||||
#endif
|
||||
case NS_NATIVE_DISPLAY:
|
||||
return (void *)GDK_DISPLAY();
|
||||
case NS_NATIVE_WIDGET:
|
||||
#ifdef NS_GTK_REF
|
||||
gtk_widget_ref(mWidget);
|
||||
#endif
|
||||
return (void *)mWidget;
|
||||
case NS_NATIVE_GRAPHIC:
|
||||
/* GetSharedGC ups the ref count on the GdkGC so make sure you release
|
||||
* it afterwards. */
|
||||
return (void *)((nsToolkit *)mToolkit)->GetSharedGC();
|
||||
default:
|
||||
g_print("nsWidget::GetNativeData(%i) - weird value\n", aDataType);
|
||||
|
@ -622,6 +631,7 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
|||
if (aNativeParent) {
|
||||
parentWidget = GTK_WIDGET(aNativeParent);
|
||||
} else if (aParent) {
|
||||
// this ups the refcount of the gtk widget, we must unref later.
|
||||
parentWidget = GTK_WIDGET(aParent->GetNativeData(NS_NATIVE_WIDGET));
|
||||
} else if(aAppShell) {
|
||||
nsNativeWidget shellWidget = aAppShell->GetNativeData(NS_NATIVE_SHELL);
|
||||
|
@ -643,6 +653,10 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
|||
DispatchStandardEvent(NS_CREATE);
|
||||
InitCallbacks();
|
||||
|
||||
#ifdef NS_GTK_REF
|
||||
gtk_widget_unref(parentWidget);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -345,12 +345,21 @@ void *nsWindow::GetNativeData(PRUint32 aDataType)
|
|||
{
|
||||
switch(aDataType) {
|
||||
case NS_NATIVE_WINDOW:
|
||||
#ifdef NS_GTK_REF
|
||||
return (void *)gdk_window_ref(GTK_LAYOUT(mWidget)->bin_window);
|
||||
#else
|
||||
return (void *)GTK_LAYOUT(mWidget)->bin_window;
|
||||
#endif
|
||||
case NS_NATIVE_DISPLAY:
|
||||
return (void *)GDK_DISPLAY();
|
||||
case NS_NATIVE_WIDGET:
|
||||
#ifdef NS_GTK_REF
|
||||
gtk_widget_ref(mWidget);
|
||||
#endif
|
||||
return (void *)mWidget;
|
||||
case NS_NATIVE_GRAPHIC:
|
||||
/* GetSharedGC ups the ref count on the GdkGC so make sure you release
|
||||
* it afterwards. */
|
||||
return (void *)((nsToolkit *)mToolkit)->GetSharedGC();
|
||||
default:
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче