зеркало из https://github.com/mozilla/gecko-dev.git
start fixing file selector, fix menus under apprunner, fix font setting for
widgets.
This commit is contained in:
Родитель
d42daa439d
Коммит
90944754dd
|
@ -79,9 +79,9 @@ PRBool nsFileWidget::Show()
|
||||||
gtk_signal_connect(GTK_OBJECT(fs->cancel_button), "clicked",
|
gtk_signal_connect(GTK_OBJECT(fs->cancel_button), "clicked",
|
||||||
GTK_SIGNAL_FUNC(file_cancel_clicked),
|
GTK_SIGNAL_FUNC(file_cancel_clicked),
|
||||||
&ret);
|
&ret);
|
||||||
|
// start new loop. ret is set in the above callbacks.
|
||||||
gtk_main();
|
gtk_main();
|
||||||
// returning true causes the browser to try and display the dir structure...
|
|
||||||
// return PR_TRUE;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +148,6 @@ NS_METHOD nsFileWidget::Create(nsIWidget *aParent,
|
||||||
|
|
||||||
mWidget = gtk_file_selection_new(title);
|
mWidget = gtk_file_selection_new(title);
|
||||||
|
|
||||||
// mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
|
||||||
// mTitle.SetLength(0);
|
|
||||||
// mTitle.Append(aTitle);
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "nsFileWidget.h"
|
#include "nsFileWidget.h"
|
||||||
#include "nsGUIEvent.h"
|
#include "nsGUIEvent.h"
|
||||||
#include "nsIMenuItem.h"
|
#include "nsIMenuItem.h"
|
||||||
|
#include "nsIMenuListener.h"
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
|
@ -566,7 +567,10 @@ gint handle_focus_out_event(GtkWidget *w, GdkEventFocus * event, gpointer p)
|
||||||
void menu_item_activate_handler(GtkWidget *w, gpointer p)
|
void menu_item_activate_handler(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
g_print("menu selected\n");
|
g_print("menu selected\n");
|
||||||
nsIMenuItem * menuItem = (nsIMenuItem *)p;
|
|
||||||
|
nsIMenuListener *menuListener = nsnull;
|
||||||
|
nsIMenuItem *menuItem = (nsIMenuItem *)p;
|
||||||
|
|
||||||
if (menuItem != NULL) {
|
if (menuItem != NULL) {
|
||||||
nsMenuEvent mevent;
|
nsMenuEvent mevent;
|
||||||
mevent.message = NS_MENU_SELECTED;
|
mevent.message = NS_MENU_SELECTED;
|
||||||
|
@ -580,7 +584,14 @@ void menu_item_activate_handler(GtkWidget *w, gpointer p)
|
||||||
mevent.time = PR_IntervalNow();
|
mevent.time = PR_IntervalNow();
|
||||||
|
|
||||||
nsEventStatus status;
|
nsEventStatus status;
|
||||||
mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status);
|
// FIXME - THIS SHOULD WORK. FIX EVENTS FOR XP CODE!!!!! (pav)
|
||||||
|
// mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status);
|
||||||
|
|
||||||
|
menuItem->QueryInterface(kIMenuListenerIID, (void**)&menuListener);
|
||||||
|
if(menuListener) {
|
||||||
|
menuListener->MenuSelected(mevent);
|
||||||
|
NS_IF_RELEASE(menuListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ nsMenuItem::nsMenuItem() : nsIMenuItem()
|
||||||
mMenuParent = nsnull;
|
mMenuParent = nsnull;
|
||||||
mPopUpParent = nsnull;
|
mPopUpParent = nsnull;
|
||||||
mTarget = nsnull;
|
mTarget = nsnull;
|
||||||
|
mXULCommandListener = nsnull;
|
||||||
mIsSeparator = PR_FALSE;
|
mIsSeparator = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,6 +299,9 @@ NS_METHOD nsMenuItem::GetNativeData(void *& aData)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener)
|
NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener)
|
||||||
{
|
{
|
||||||
|
NS_IF_RELEASE(mXULCommandListener);
|
||||||
|
NS_IF_ADDREF(aMenuListener);
|
||||||
|
mXULCommandListener = aMenuListener;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +323,9 @@ NS_METHOD nsMenuItem::IsSeparator(PRBool & aIsSep)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsEventStatus nsMenuItem::MenuSelected(const nsMenuEvent & aMenuEvent)
|
nsEventStatus nsMenuItem::MenuSelected(const nsMenuEvent & aMenuEvent)
|
||||||
{
|
{
|
||||||
|
if(mXULCommandListener)
|
||||||
|
return mXULCommandListener->MenuSelected(aMenuEvent);
|
||||||
|
|
||||||
g_print("nsMenuItem::MenuSelected\n");
|
g_print("nsMenuItem::MenuSelected\n");
|
||||||
return nsEventStatus_eIgnore;
|
return nsEventStatus_eIgnore;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ protected:
|
||||||
nsIWidget *GetMenuBarParent(nsISupports * aParentSupports);
|
nsIWidget *GetMenuBarParent(nsISupports * aParentSupports);
|
||||||
GtkWidget *GetNativeParent();
|
GtkWidget *GetNativeParent();
|
||||||
|
|
||||||
|
nsIMenuListener *mXULCommandListener;
|
||||||
nsString mLabel;
|
nsString mLabel;
|
||||||
PRUint32 mCommand;
|
PRUint32 mCommand;
|
||||||
nsIMenu *mMenuParent;
|
nsIMenu *mMenuParent;
|
||||||
|
|
|
@ -324,24 +324,31 @@ nsIFontMetrics *nsWidget::GetFont(void)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
NS_METHOD nsWidget::SetFont(const nsFont &aFont)
|
NS_METHOD nsWidget::SetFont(const nsFont &aFont)
|
||||||
{
|
{
|
||||||
|
|
||||||
nsIFontMetrics* mFontMetrics;
|
nsIFontMetrics* mFontMetrics;
|
||||||
mContext->GetMetricsFor(aFont, mFontMetrics);
|
mContext->GetMetricsFor(aFont, mFontMetrics);
|
||||||
|
|
||||||
if (mFontMetrics) {
|
if (mFontMetrics) {
|
||||||
nsFontHandle fontHandle;
|
nsFontHandle fontHandle;
|
||||||
mFontMetrics->GetFontHandle(fontHandle);
|
mFontMetrics->GetFontHandle(fontHandle);
|
||||||
|
gtk_widget_ensure_style(mWidget);
|
||||||
|
|
||||||
GtkStyle* style;
|
GtkStyle *style = gtk_style_copy(mWidget->style);
|
||||||
style= gtk_widget_get_style(mWidget);
|
// gtk_style_copy ups the ref count of the font
|
||||||
gdk_font_unref (style->font);
|
gdk_font_unref (style->font);
|
||||||
|
|
||||||
style->font = (GdkFont *)fontHandle;
|
GdkFontPrivate *pvt;
|
||||||
|
|
||||||
|
pvt = (GdkFontPrivate*) style->font;
|
||||||
|
g_print("font refcount: %i\n",pvt->ref_count);
|
||||||
|
|
||||||
|
GdkFont *font = (GdkFont *)fontHandle;
|
||||||
|
style->font = font;
|
||||||
gdk_font_ref(style->font);
|
gdk_font_ref(style->font);
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_set_style(mWidget, style);
|
gtk_widget_set_style(mWidget, style);
|
||||||
|
|
||||||
|
gtk_style_unref(style);
|
||||||
|
|
||||||
}
|
}
|
||||||
NS_RELEASE(mFontMetrics);
|
NS_RELEASE(mFontMetrics);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -583,7 +590,6 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
||||||
|
|
||||||
gtk_widget_push_colormap(gdk_rgb_get_cmap());
|
gtk_widget_push_colormap(gdk_rgb_get_cmap());
|
||||||
gtk_widget_push_visual(gdk_rgb_get_visual());
|
gtk_widget_push_visual(gdk_rgb_get_visual());
|
||||||
gtk_widget_push_style(gtk_style_new());
|
|
||||||
|
|
||||||
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
|
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
|
||||||
aAppShell, aToolkit, aInitData);
|
aAppShell, aToolkit, aInitData);
|
||||||
|
@ -608,7 +614,6 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
||||||
|
|
||||||
gtk_widget_pop_colormap();
|
gtk_widget_pop_colormap();
|
||||||
gtk_widget_pop_visual();
|
gtk_widget_pop_visual();
|
||||||
gtk_widget_pop_style ();
|
|
||||||
|
|
||||||
DispatchStandardEvent(NS_CREATE);
|
DispatchStandardEvent(NS_CREATE);
|
||||||
InitCallbacks();
|
InitCallbacks();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче