Commit 8923d60d authored by Jay Painter's avatar Jay Painter
Browse files

CList signal revert (right back at you! *ouch*)

parent 9ad92229
......@@ -92,11 +92,10 @@ COLUMN_FROM_XPIXEL (GtkCList * clist,
(clist)->column[(clist)->columns - 1].area.width + \
COLUMN_INSET + CELL_SPACING)
/* Signals */
enum
{
MOUSE_CLICK,
MOUSE_DOUBLE_CLICK,
SELECT_ROW,
UNSELECT_ROW,
CLICK_COLUMN,
......@@ -106,7 +105,7 @@ enum
typedef void (*GtkCListSignal1) (GtkObject * object,
gint arg1,
gint arg2,
gint arg3,
GdkEventButton * arg3,
gpointer data);
typedef void (*GtkCListSignal2) (GtkObject * object,
......@@ -165,11 +164,11 @@ static void size_allocate_columns (GtkCList * clist);
static void real_select_row (GtkCList * clist,
gint row,
gint column,
gint button);
GdkEventButton * event);
static void real_unselect_row (GtkCList * clist,
gint row,
gint column,
gint button);
GdkEventButton * event);
static gint get_selection_info (GtkCList * clist,
gint x,
gint y,
......@@ -249,11 +248,13 @@ static void gtk_clist_marshal_signal_2 (GtkObject * object,
GtkArg * args);
/* Fill in data after widget is realized and has style */
static void add_style_data (GtkCList * clist);
static GtkContainerClass *parent_class = NULL;
static gint clist_signals[LAST_SIGNAL] = {0};
guint
gtk_clist_get_type ()
{
......@@ -290,34 +291,21 @@ gtk_clist_class_init (GtkCListClass * klass)
container_class = (GtkContainerClass *) klass;
parent_class = gtk_type_class (gtk_container_get_type ());
clist_signals[MOUSE_CLICK] =
gtk_signal_new ("mouse_click",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkCListClass, mouse_click),
gtk_clist_marshal_signal_1,
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT);
clist_signals[MOUSE_DOUBLE_CLICK] =
gtk_signal_new ("mouse_double_click",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkCListClass, mouse_double_click),
gtk_clist_marshal_signal_1,
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT);
clist_signals[SELECT_ROW] =
gtk_signal_new ("select_row",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkCListClass, select_row),
gtk_clist_marshal_signal_1,
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT);
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER);
clist_signals[UNSELECT_ROW] =
gtk_signal_new ("unselect_row",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkCListClass, unselect_row),
gtk_clist_marshal_signal_1,
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT);
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER);
clist_signals[CLICK_COLUMN] =
gtk_signal_new ("click_column",
GTK_RUN_LAST,
......@@ -347,8 +335,6 @@ gtk_clist_class_init (GtkCListClass * klass)
container_class->remove = NULL;
container_class->foreach = gtk_clist_foreach;
klass->mouse_click = NULL;
klass->mouse_double_click = NULL;
klass->select_row = real_select_row;
klass->unselect_row = real_unselect_row;
klass->click_column = NULL;
......@@ -366,10 +352,9 @@ gtk_clist_marshal_signal_1 (GtkObject * object,
rfunc = (GtkCListSignal1) func;
(*rfunc) (object,
GTK_VALUE_INT (args[0]),
(*rfunc) (object, GTK_VALUE_INT (args[0]),
GTK_VALUE_INT (args[1]),
GTK_VALUE_INT (args[2]),
GTK_VALUE_POINTER (args[2]),
func_data);
}
......@@ -383,8 +368,7 @@ gtk_clist_marshal_signal_2 (GtkObject * object,
rfunc = (GtkCListSignal2) func;
(*rfunc) (object,
GTK_VALUE_INT (args[0]),
(*rfunc) (object, GTK_VALUE_INT (args[0]),
func_data);
}
......@@ -828,7 +812,7 @@ gtk_clist_set_row_height (GtkCList * clist,
if (GTK_WIDGET_REALIZED (clist))
{
text_height = height - (GTK_WIDGET (clist)->style->font->ascent +
GTK_WIDGET (clist)->style->font->descent + 1);
GTK_WIDGET (clist) ->style->font->descent + 1);
clist->row_center_offset = (text_height / 2) + GTK_WIDGET (clist)->style->font->ascent + 1.5;
}
......@@ -1441,7 +1425,7 @@ gtk_clist_select_row (GtkCList * clist,
if (column < -1 || column >= clist->columns)
return;
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW], row, column, 0);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW], row, column, NULL);
}
void
......@@ -1457,7 +1441,7 @@ gtk_clist_unselect_row (GtkCList * clist,
if (column < -1 || column >= clist->columns)
return;
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], row, column, 0);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], row, column, NULL);
}
gint
......@@ -1920,25 +1904,8 @@ gtk_clist_button_press (GtkWidget * widget,
y = event->y;
if (get_selection_info (clist, x, y, &row, &column))
{
switch (event->type)
{
case GDK_BUTTON_PRESS:
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[MOUSE_CLICK],
row, column, event->button);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
row, column, event->button);
break;
case GDK_2BUTTON_PRESS:
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[MOUSE_DOUBLE_CLICK],
row, column, event->button);
break;
default:
break;
}
}
row, column, event);
return FALSE;
}
......@@ -2757,7 +2724,7 @@ static void
real_select_row (GtkCList * clist,
gint row,
gint column,
gint button)
GdkEventButton * event)
{
gint i;
GList *list;
......@@ -2783,7 +2750,8 @@ real_select_row (GtkCList * clist,
if (clist_row->state == GTK_STATE_SELECTED)
{
clist_row->state = GTK_STATE_NORMAL;
gtk_clist_unselect_row (clist, i, column);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
i, column, event);
}
else
{
......@@ -2796,7 +2764,8 @@ real_select_row (GtkCList * clist,
}
else if (clist_row->state == GTK_STATE_SELECTED)
{
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], i, column, button);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
i, column, event);
}
i++;
......@@ -2824,7 +2793,8 @@ real_select_row (GtkCList * clist,
}
else if (clist_row->state == GTK_STATE_SELECTED)
{
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], i, column, button);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
i, column, event);
}
i++;
......@@ -2844,7 +2814,8 @@ real_select_row (GtkCList * clist,
if (clist_row->state == GTK_STATE_SELECTED)
{
clist_row->state = GTK_STATE_NORMAL;
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], i, column, button);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
i, column, event);
}
else
{
......@@ -2872,7 +2843,7 @@ static void
real_unselect_row (GtkCList * clist,
gint row,
gint column,
gint button)
GdkEventButton * event)
{
GtkCListRow *clist_row;
......
......@@ -110,7 +110,7 @@ struct _GtkCList
/* dynamicly allocated array of column structures */
GtkCListColumn *column;
/* the scrolling window and it's height and width to
/*the scrolling window and it's height and width to
* make things a little speedier */
GdkWindow *clist_window;
gint clist_window_width;
......@@ -153,26 +153,14 @@ struct _GtkCListClass
{
GtkContainerClass parent_class;
void (*mouse_click) (GtkCList * clist,
gint row,
gint column,
gint button);
void (*mouse_double_click) (GtkCList * clist,
gint row,
gint column,
gint button);
void (*select_row) (GtkCList * clist,
gint row,
gint column,
gint button);
GdkEventButton * event);
void (*unselect_row) (GtkCList * clist,
gint row,
gint column,
gint button);
GdkEventButton * event);
void (*click_column) (GtkCList * clist,
gint column);
......
......@@ -286,25 +286,13 @@ static gint gtk_file_selection_key_press (GtkWidget *widget,
static void gtk_file_selection_file_button (GtkWidget *widget,
gint row,
gint column,
gint button,
gpointer user_data);
static void gtk_file_selection_file_button_double (GtkWidget *widget,
gint row,
gint column,
gint button,
GdkEventButton *bevent,
gpointer user_data);
static void gtk_file_selection_dir_button (GtkWidget *widget,
gint row,
gint column,
gint button,
gpointer data);
static void gtk_file_selection_dir_button_double (GtkWidget *widget,
gint row,
gint column,
gint button,
GdkEventButton *bevent,
gpointer data);
static void gtk_file_selection_populate (GtkFileSelection *fs,
......@@ -440,9 +428,6 @@ gtk_file_selection_init (GtkFileSelection *filesel)
gtk_signal_connect (GTK_OBJECT (filesel->dir_list), "select_row",
(GtkSignalFunc) gtk_file_selection_dir_button,
(gpointer) filesel);
gtk_signal_connect (GTK_OBJECT (filesel->dir_list), "mouse_double_click",
(GtkSignalFunc) gtk_file_selection_dir_button_double,
(gpointer) filesel);
gtk_clist_set_policy (GTK_CLIST (filesel->dir_list), GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
gtk_clist_column_titles_passive (GTK_CLIST (filesel->dir_list));
gtk_container_border_width (GTK_CONTAINER (filesel->dir_list), 5);
......@@ -455,9 +440,6 @@ gtk_file_selection_init (GtkFileSelection *filesel)
gtk_signal_connect (GTK_OBJECT (filesel->file_list), "select_row",
(GtkSignalFunc) gtk_file_selection_file_button,
(gpointer) filesel);
gtk_signal_connect (GTK_OBJECT (filesel->file_list), "mouse_double_click",
(GtkSignalFunc) gtk_file_selection_file_button_double,
(gpointer) filesel);
gtk_clist_set_policy (GTK_CLIST (filesel->file_list), GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
gtk_clist_column_titles_passive (GTK_CLIST (filesel->file_list));
gtk_container_border_width (GTK_CONTAINER (filesel->file_list), 5);
......@@ -1112,7 +1094,7 @@ static void
gtk_file_selection_file_button (GtkWidget *widget,
gint row,
gint column,
gint button,
GdkEventButton *bevent,
gpointer user_data)
{
GtkFileSelection *fs = NULL;
......@@ -1126,37 +1108,29 @@ gtk_file_selection_file_button (GtkWidget *widget,
filename = gtk_clist_get_row_data (GTK_CLIST (fs->file_list), row);
if (filename)
if (bevent && filename)
{
switch (bevent->type)
{
case GDK_BUTTON_PRESS:
gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
}
static void
gtk_file_selection_file_button_double (GtkWidget *widget,
gint row,
gint column,
gint button,
gpointer user_data)
{
GtkFileSelection *fs = NULL;
gchar *filename;
g_return_if_fail (GTK_IS_CLIST (widget));
fs = user_data;
g_return_if_fail (fs != NULL);
g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
filename = gtk_clist_get_row_data (GTK_CLIST (fs->file_list), row);
break;
if (filename)
case GDK_2BUTTON_PRESS:
gtk_button_clicked (GTK_BUTTON (fs->ok_button));
break;
default:
break;
}
}
}
static void
gtk_file_selection_dir_button (GtkWidget *widget,
gint row,
gint column,
gint button,
GdkEventButton *bevent,
gpointer user_data)
{
GtkFileSelection *fs = NULL;
......@@ -1170,30 +1144,22 @@ gtk_file_selection_dir_button (GtkWidget *widget,
filename = gtk_clist_get_row_data (GTK_CLIST (fs->dir_list), row);
if (filename)
gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
}
static void
gtk_file_selection_dir_button_double (GtkWidget *widget,
gint row,
gint column,
gint button,
gpointer user_data)
{
GtkFileSelection *fs = NULL;
gchar *filename;
if (bevent && filename) {
g_return_if_fail (GTK_IS_CLIST (widget));
fs = GTK_FILE_SELECTION (user_data);
g_return_if_fail (fs != NULL);
g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
filename = gtk_clist_get_row_data (GTK_CLIST (fs->dir_list), row);
switch (bevent->type)
{
case GDK_BUTTON_PRESS:
gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
break;
if (filename)
case GDK_2BUTTON_PRESS:
gtk_file_selection_populate (fs, filename, FALSE);
break;
default:
break;
}
}
}
static void
......
......@@ -1659,31 +1659,11 @@ hide_titles_clist (GtkWidget *widget, gpointer data)
gtk_clist_column_titles_hide (GTK_CLIST (data));
}
void
mouse_click_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
{
g_print ("GtkCList Mouse Click: row %d column %d button %d\n",
row, column, button);
}
void
mouse_double_click_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
{
g_print ("GtkCList Mouse Double Click: row %d column %d button %d\n",
row, column, button);
}
void
select_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
GdkEventButton * bevent)
{
gint i;
guint8 spacing;
......@@ -1692,7 +1672,7 @@ select_clist (GtkWidget *widget,
GdkBitmap *mask;
g_print ("GtkCList Selection: row %d column %d button %d\n",
row, column, button);
row, column, bevent ? bevent->button : 0);
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
{
......@@ -1730,55 +1710,6 @@ select_clist (GtkWidget *widget,
clist_selected_row = row;
}
void
unselect_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
{
gint i;
guint8 spacing;
gchar *text;
GdkPixmap *pixmap;
GdkBitmap *mask;
g_print ("GtkCList UnSelection: row %d column %d button %d\n",
row, column, button);
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
{
switch (gtk_clist_get_cell_type (GTK_CLIST (widget), row, i))
{
case GTK_CELL_TEXT:
g_print ("CELL %d GTK_CELL_TEXT\n", i);
gtk_clist_get_text (GTK_CLIST (widget), row, i, &text);
g_print ("TEXT: %s\n", text);
break;
case GTK_CELL_PIXMAP:
g_print ("CELL %d GTK_CELL_PIXMAP\n", i);
gtk_clist_get_pixmap (GTK_CLIST (widget), row, i, &pixmap, &mask);
g_print ("PIXMAP: %d\n", (int) pixmap);
g_print ("MASK: %d\n", (int) mask);
break;
case GTK_CELL_PIXTEXT:
g_print ("CELL %d GTK_CELL_PIXTEXT\n", i);
gtk_clist_get_pixtext (GTK_CLIST (widget), row, i, &text, &spacing, &pixmap, &mask);
g_print ("TEXT: %s\n", text);
g_print ("SPACING: %d\n", spacing);
g_print ("PIXMAP: %d\n", (int) pixmap);
g_print ("MASK: %d\n", (int) mask);
break;
default:
break;
}
}
g_print ("\n\n");
}
void
list_selection_clist (GtkWidget *widget, gpointer data)
{
......@@ -1920,22 +1851,10 @@ create_clist ()
*/
gtk_clist_set_row_height (GTK_CLIST (clist), 20);
gtk_signal_connect (GTK_OBJECT (clist),
"mouse_click",
(GtkSignalFunc) mouse_click_clist,
NULL);
gtk_signal_connect (GTK_OBJECT (clist),
"mouse_double_click",
(GtkSignalFunc) mouse_double_click_clist,
NULL);
gtk_signal_connect (GTK_OBJECT (clist),
"select_row",
(GtkSignalFunc) select_clist,
NULL);
gtk_signal_connect (GTK_OBJECT (clist),
"unselect_row",
(GtkSignalFunc) unselect_clist,
NULL);
gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100);
......
......@@ -1659,31 +1659,11 @@ hide_titles_clist (GtkWidget *widget, gpointer data)
gtk_clist_column_titles_hide (GTK_CLIST (data));
}
void
mouse_click_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
{
g_print ("GtkCList Mouse Click: row %d column %d button %d\n",
row, column, button);
}
void
mouse_double_click_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
{
g_print ("GtkCList Mouse Double Click: row %d column %d button %d\n",
row, column, button);
}
void
select_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
GdkEventButton * bevent)
{
gint i;
guint8 spacing;
......@@ -1692,7 +1672,7 @@ select_clist (GtkWidget *widget,
GdkBitmap *mask;
g_print ("GtkCList Selection: row %d column %d button %d\n",
row, column, button);
row, column, bevent ? bevent->button : 0);
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
{
......@@ -1730,55 +1710,6 @@ select_clist (GtkWidget *widget,
clist_selected_row = row;
}
void
unselect_clist (GtkWidget *widget,
gint row,
gint column,
gint button)
{
gint i;
guint8 spacing;
gchar *text;
GdkPixmap *pixmap;
GdkBitmap *mask;
g_print ("GtkCList UnSelection: row %d column %d button %d\n",
row, column, button);
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
{
switch (gtk_clist_get_cell_type (GTK_CLIST (widget), row, i))
{
case GTK_CELL_TEXT:
g_print ("CELL %d GTK_CELL_TEXT\n", i);
gtk_clist_get_text (GTK_CLIST (widget), row, i, &text);
g_print ("TEXT: %s\n", text);
break;
case GTK_CELL_PIXMAP:
g_print ("CELL %d GTK_CELL_PIXMAP\n", i);
gtk_clist_get_pixmap (GTK_CLIST (widget), row, i, &pixmap, &mask);
g_print ("PIXMAP: %d\n", (int) pixmap);
g_print ("MASK: %d\n", (int) mask);
break;
case GTK_CELL_PIXTEXT:
g_print ("CELL %d GTK_CELL_PIXTEXT\n", i);
gtk_clist_get_pixtext (GTK_CLIST (widget), row, i, &text, &spacing, &pixmap, &mask);
g_print ("TEXT: %s\n", text);
g_print ("SPACING: %d\n", spacing);
g_print ("PIXMAP: %d\n", (int) pixmap);
g_print ("MASK: %d\n", (int) mask);
break;
default:
break;
}
}
g_print ("\n\n");
}
void
list_selection_clist (GtkWidget *widget, gpointer data)
{
......@@ -1920,22 +1851,10 @@ create_clist ()
*/
gtk_clist_set_row_height (GTK_CLIST (clist), 20);