fix assertions when adding events

This commit is contained in:
pavlov%pavlov.net 1999-05-15 16:14:48 +00:00
Родитель c1c0276f47
Коммит 41802abebe
4 изменённых файлов: 29 добавлений и 23 удалений

Просмотреть файл

@ -59,6 +59,7 @@ nsComboBox::~nsComboBox()
}
g_list_free(mItems);
}
gtk_widget_destroy(mCombo);
}
void nsComboBox::InitCallbacks(char * aName)
@ -123,18 +124,18 @@ PRInt32 nsComboBox::FindItem(nsString &aItem, PRInt32 aStartPos)
{
NS_ALLOC_STR_BUF(val, aItem, 256);
int i;
PRInt32 index = -1;
PRInt32 inx = -1;
GList *items = g_list_nth(mItems, aStartPos);
for(i=0; items != NULL; items = (GList *) g_list_next(items), i++ )
{
if(!strcmp(val, (gchar *) items->data))
{
index = i;
inx = i;
break;
}
}
NS_FREE_STR_BUF(val);
return index;
return inx;
}
//-------------------------------------------------------------------------
@ -307,18 +308,22 @@ NS_METHOD nsComboBox::CreateNative(GtkWidget *parentWindow)
add it inside an alignment set the usize on it..
(set xscale yscale for the alignment to 1.0)
*/
mWidget = ::gtk_alignment_new(1.0,1.0,1.0,1.0);
mWidget = ::gtk_event_box_new();
mAlign = ::gtk_alignment_new(1.0,1.0,1.0,1.0);
::gtk_widget_set_name(mWidget, "nsComboBox");
mCombo = ::gtk_combo_new();
gtk_widget_show(mCombo);
/* make the stuff uneditable */
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(mCombo)->entry), PR_FALSE);
gtk_container_add(GTK_CONTAINER(mWidget), mCombo);
gtk_container_add(GTK_CONTAINER(mAlign), mCombo);
gtk_signal_connect(GTK_OBJECT(mCombo),
"destroy",
GTK_SIGNAL_FUNC(DestroySignal),
this);
gtk_container_add(GTK_CONTAINER(mWidget), mAlign);
return NS_OK;
}

Просмотреть файл

@ -64,6 +64,7 @@ protected:
virtual void InitCallbacks(char * aName = nsnull);
virtual void OnDestroySignal(GtkWidget* aGtkWidget);
GtkWidget *mAlign; /* workaround for gtkcombo bug */
GtkWidget *mCombo; /* workaround for gtkcombo bug */
GList *mItems;
PRBool mMultiSelect;

Просмотреть файл

@ -50,14 +50,14 @@ nsListBox::~nsListBox()
void nsListBox::InitCallbacks(char * aName)
{
InstallButtonPressSignal(mWidget);
InstallButtonReleaseSignal(mWidget);
InstallButtonPressSignal(mCList);
InstallButtonReleaseSignal(mCList);
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
InstallEnterNotifySignal(mCList);
InstallLeaveNotifySignal(mCList);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
AddToEventMask(mCList,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
@ -147,14 +147,14 @@ NS_METHOD nsListBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
//-------------------------------------------------------------------------
PRInt32 nsListBox::FindItem(nsString &aItem, PRInt32 aStartPos)
{
int index = -1;
int i = -1;
if (mCList) {
index = gtk_clist_find_row_from_data(GTK_CLIST(mCList), (gpointer)&aItem);
if (index < aStartPos) {
index = -1;
i = gtk_clist_find_row_from_data(GTK_CLIST(mCList), (gpointer)&aItem);
if (i < aStartPos) {
i = -1;
}
}
return index;
return i;
}
//-------------------------------------------------------------------------
@ -214,11 +214,11 @@ NS_METHOD nsListBox::GetSelectedItem(nsString& aItem)
{
aItem.Truncate();
if (mCList) {
PRInt32 i=0, index=-1;
PRInt32 i=0, idx=-1;
GtkCList *clist = GTK_CLIST(mCList);
GList *list = clist->row_list;
for (i=0; i < clist->rows && index == -1; i++, list = list->next) {
for (i=0; i < clist->rows && idx == -1; i++, list = list->next) {
if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED) {
char *text = nsnull;
gtk_clist_get_text(GTK_CLIST(mCList),i,0,&text);
@ -239,22 +239,22 @@ NS_METHOD nsListBox::GetSelectedItem(nsString& aItem)
//-------------------------------------------------------------------------
PRInt32 nsListBox::GetSelectedIndex()
{
PRInt32 i=0, index=-1;
PRInt32 i=0, idx=-1;
if (mCList) {
if (!mMultiSelect) {
GtkCList *clist = GTK_CLIST(mCList);
GList *list = clist->row_list;
for (i=0; i < clist->rows && index == -1; i++, list = list->next) {
for (i=0; i < clist->rows && idx == -1; i++, list = list->next) {
if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED) {
index = i;
idx = i;
}
}
} else {
NS_ASSERTION(PR_FALSE, "Multi selection list box does not support GetSelectedIndex()");
}
}
return index;
return idx;
}
//-------------------------------------------------------------------------

Просмотреть файл

@ -312,8 +312,8 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
// Force cursor to default setting
gtk_widget_set_name(mWidget, "nsWindow");
mCursor = eCursor_select;
SetCursor(eCursor_standard);
// mCursor = eCursor_select;
// SetCursor(eCursor_standard);
return NS_OK;
}