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, ...@@ -92,11 +92,10 @@ COLUMN_FROM_XPIXEL (GtkCList * clist,
(clist)->column[(clist)->columns - 1].area.width + \ (clist)->column[(clist)->columns - 1].area.width + \
COLUMN_INSET + CELL_SPACING) COLUMN_INSET + CELL_SPACING)
/* Signals */ /* Signals */
enum enum
{ {
MOUSE_CLICK,
MOUSE_DOUBLE_CLICK,
SELECT_ROW, SELECT_ROW,
UNSELECT_ROW, UNSELECT_ROW,
CLICK_COLUMN, CLICK_COLUMN,
...@@ -106,7 +105,7 @@ enum ...@@ -106,7 +105,7 @@ enum
typedef void (*GtkCListSignal1) (GtkObject * object, typedef void (*GtkCListSignal1) (GtkObject * object,
gint arg1, gint arg1,
gint arg2, gint arg2,
gint arg3, GdkEventButton * arg3,
gpointer data); gpointer data);
typedef void (*GtkCListSignal2) (GtkObject * object, typedef void (*GtkCListSignal2) (GtkObject * object,
...@@ -165,11 +164,11 @@ static void size_allocate_columns (GtkCList * clist); ...@@ -165,11 +164,11 @@ static void size_allocate_columns (GtkCList * clist);
static void real_select_row (GtkCList * clist, static void real_select_row (GtkCList * clist,
gint row, gint row,
gint column, gint column,
gint button); GdkEventButton * event);
static void real_unselect_row (GtkCList * clist, static void real_unselect_row (GtkCList * clist,
gint row, gint row,
gint column, gint column,
gint button); GdkEventButton * event);
static gint get_selection_info (GtkCList * clist, static gint get_selection_info (GtkCList * clist,
gint x, gint x,
gint y, gint y,
...@@ -249,11 +248,13 @@ static void gtk_clist_marshal_signal_2 (GtkObject * object, ...@@ -249,11 +248,13 @@ static void gtk_clist_marshal_signal_2 (GtkObject * object,
GtkArg * args); GtkArg * args);
/* Fill in data after widget is realized and has style */ /* Fill in data after widget is realized and has style */
static void add_style_data (GtkCList * clist); static void add_style_data (GtkCList * clist);
static GtkContainerClass *parent_class = NULL; static GtkContainerClass *parent_class = NULL;
static gint clist_signals[LAST_SIGNAL] = {0}; static gint clist_signals[LAST_SIGNAL] = {0};
guint guint
gtk_clist_get_type () gtk_clist_get_type ()
{ {
...@@ -290,34 +291,21 @@ gtk_clist_class_init (GtkCListClass * klass) ...@@ -290,34 +291,21 @@ gtk_clist_class_init (GtkCListClass * klass)
container_class = (GtkContainerClass *) klass; container_class = (GtkContainerClass *) klass;
parent_class = gtk_type_class (gtk_container_get_type ()); 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] = clist_signals[SELECT_ROW] =
gtk_signal_new ("select_row", gtk_signal_new ("select_row",
GTK_RUN_LAST, GTK_RUN_LAST,
object_class->type, object_class->type,
GTK_SIGNAL_OFFSET (GtkCListClass, select_row), GTK_SIGNAL_OFFSET (GtkCListClass, select_row),
gtk_clist_marshal_signal_1, 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] = clist_signals[UNSELECT_ROW] =
gtk_signal_new ("unselect_row", gtk_signal_new ("unselect_row",
GTK_RUN_LAST, GTK_RUN_LAST,
object_class->type, object_class->type,
GTK_SIGNAL_OFFSET (GtkCListClass, unselect_row), GTK_SIGNAL_OFFSET (GtkCListClass, unselect_row),
gtk_clist_marshal_signal_1, 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] = clist_signals[CLICK_COLUMN] =
gtk_signal_new ("click_column", gtk_signal_new ("click_column",
GTK_RUN_LAST, GTK_RUN_LAST,
...@@ -347,8 +335,6 @@ gtk_clist_class_init (GtkCListClass * klass) ...@@ -347,8 +335,6 @@ gtk_clist_class_init (GtkCListClass * klass)
container_class->remove = NULL; container_class->remove = NULL;
container_class->foreach = gtk_clist_foreach; container_class->foreach = gtk_clist_foreach;
klass->mouse_click = NULL;
klass->mouse_double_click = NULL;
klass->select_row = real_select_row; klass->select_row = real_select_row;
klass->unselect_row = real_unselect_row; klass->unselect_row = real_unselect_row;
klass->click_column = NULL; klass->click_column = NULL;
...@@ -366,10 +352,9 @@ gtk_clist_marshal_signal_1 (GtkObject * object, ...@@ -366,10 +352,9 @@ gtk_clist_marshal_signal_1 (GtkObject * object,
rfunc = (GtkCListSignal1) func; rfunc = (GtkCListSignal1) func;
(*rfunc) (object, (*rfunc) (object, GTK_VALUE_INT (args[0]),
GTK_VALUE_INT (args[0]),
GTK_VALUE_INT (args[1]), GTK_VALUE_INT (args[1]),
GTK_VALUE_INT (args[2]), GTK_VALUE_POINTER (args[2]),
func_data); func_data);
} }
...@@ -383,8 +368,7 @@ gtk_clist_marshal_signal_2 (GtkObject * object, ...@@ -383,8 +368,7 @@ gtk_clist_marshal_signal_2 (GtkObject * object,
rfunc = (GtkCListSignal2) func; rfunc = (GtkCListSignal2) func;
(*rfunc) (object, (*rfunc) (object, GTK_VALUE_INT (args[0]),
GTK_VALUE_INT (args[0]),
func_data); func_data);
} }
...@@ -828,7 +812,7 @@ gtk_clist_set_row_height (GtkCList * clist, ...@@ -828,7 +812,7 @@ gtk_clist_set_row_height (GtkCList * clist,
if (GTK_WIDGET_REALIZED (clist)) if (GTK_WIDGET_REALIZED (clist))
{ {
text_height = height - (GTK_WIDGET (clist)->style->font->ascent + 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; 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, ...@@ -1441,7 +1425,7 @@ gtk_clist_select_row (GtkCList * clist,
if (column < -1 || column >= clist->columns) if (column < -1 || column >= clist->columns)
return; 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 void
...@@ -1457,7 +1441,7 @@ gtk_clist_unselect_row (GtkCList * clist, ...@@ -1457,7 +1441,7 @@ gtk_clist_unselect_row (GtkCList * clist,
if (column < -1 || column >= clist->columns) if (column < -1 || column >= clist->columns)
return; 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 gint
...@@ -1920,25 +1904,8 @@ gtk_clist_button_press (GtkWidget * widget, ...@@ -1920,25 +1904,8 @@ gtk_clist_button_press (GtkWidget * widget,
y = event->y; y = event->y;
if (get_selection_info (clist, x, y, &row, &column)) if (get_selection_info (clist, x, y, &row, &column))
{ gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
switch (event->type) row, column, event);
{
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;
}
}
return FALSE; return FALSE;
} }
...@@ -2757,7 +2724,7 @@ static void ...@@ -2757,7 +2724,7 @@ static void
real_select_row (GtkCList * clist, real_select_row (GtkCList * clist,
gint row, gint row,
gint column, gint column,
gint button) GdkEventButton * event)
{ {
gint i; gint i;
GList *list; GList *list;
...@@ -2783,7 +2750,8 @@ real_select_row (GtkCList * clist, ...@@ -2783,7 +2750,8 @@ real_select_row (GtkCList * clist,
if (clist_row->state == GTK_STATE_SELECTED) if (clist_row->state == GTK_STATE_SELECTED)
{ {
clist_row->state = GTK_STATE_NORMAL; 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 else
{ {
...@@ -2796,7 +2764,8 @@ real_select_row (GtkCList * clist, ...@@ -2796,7 +2764,8 @@ real_select_row (GtkCList * clist,
} }
else if (clist_row->state == GTK_STATE_SELECTED) 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++; i++;
...@@ -2824,7 +2793,8 @@ real_select_row (GtkCList * clist, ...@@ -2824,7 +2793,8 @@ real_select_row (GtkCList * clist,
} }
else if (clist_row->state == GTK_STATE_SELECTED) 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++; i++;
...@@ -2844,7 +2814,8 @@ real_select_row (GtkCList * clist, ...@@ -2844,7 +2814,8 @@ real_select_row (GtkCList * clist,
if (clist_row->state == GTK_STATE_SELECTED) if (clist_row->state == GTK_STATE_SELECTED)
{ {
clist_row->state = GTK_STATE_NORMAL; 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 else
{ {
...@@ -2872,7 +2843,7 @@ static void ...@@ -2872,7 +2843,7 @@ static void
real_unselect_row (GtkCList * clist, real_unselect_row (GtkCList * clist,
gint row, gint row,
gint column, gint column,
gint button) GdkEventButton * event)
{ {
GtkCListRow *clist_row; GtkCListRow *clist_row;
......
...@@ -110,7 +110,7 @@ struct _GtkCList ...@@ -110,7 +110,7 @@ struct _GtkCList
/* dynamicly allocated array of column structures */ /* dynamicly allocated array of column structures */
GtkCListColumn *column; 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 */ * make things a little speedier */
GdkWindow *clist_window; GdkWindow *clist_window;
gint clist_window_width; gint clist_window_width;
...@@ -153,26 +153,14 @@ struct _GtkCListClass ...@@ -153,26 +153,14 @@ struct _GtkCListClass
{ {
GtkContainerClass parent_class; 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, void (*select_row) (GtkCList * clist,
gint row, gint row,
gint column, gint column,
gint button); GdkEventButton * event);
void (*unselect_row) (GtkCList * clist, void (*unselect_row) (GtkCList * clist,
gint row, gint row,
gint column, gint column,
gint button); GdkEventButton * event);
void (*click_column) (GtkCList * clist, void (*click_column) (GtkCList * clist,
gint column); gint column);
......
...@@ -286,27 +286,15 @@ static gint gtk_file_selection_key_press (GtkWidget *widget, ...@@ -286,27 +286,15 @@ static gint gtk_file_selection_key_press (GtkWidget *widget,
static void gtk_file_selection_file_button (GtkWidget *widget, static void gtk_file_selection_file_button (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
gint button, GdkEventButton *bevent,
gpointer user_data); gpointer user_data);
static void gtk_file_selection_file_button_double (GtkWidget *widget,
gint row,
gint column,
gint button,
gpointer user_data);
static void gtk_file_selection_dir_button (GtkWidget *widget, static void gtk_file_selection_dir_button (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
gint button, GdkEventButton *bevent,
gpointer data); gpointer data);
static void gtk_file_selection_dir_button_double (GtkWidget *widget,
gint row,
gint column,
gint button,
gpointer data);
static void gtk_file_selection_populate (GtkFileSelection *fs, static void gtk_file_selection_populate (GtkFileSelection *fs,
gchar *rel_path, gchar *rel_path,
gint try_complete); gint try_complete);
...@@ -440,9 +428,6 @@ gtk_file_selection_init (GtkFileSelection *filesel) ...@@ -440,9 +428,6 @@ gtk_file_selection_init (GtkFileSelection *filesel)
gtk_signal_connect (GTK_OBJECT (filesel->dir_list), "select_row", gtk_signal_connect (GTK_OBJECT (filesel->dir_list), "select_row",
(GtkSignalFunc) gtk_file_selection_dir_button, (GtkSignalFunc) gtk_file_selection_dir_button,
(gpointer) filesel); (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_set_policy (GTK_CLIST (filesel->dir_list), GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
gtk_clist_column_titles_passive (GTK_CLIST (filesel->dir_list)); gtk_clist_column_titles_passive (GTK_CLIST (filesel->dir_list));
gtk_container_border_width (GTK_CONTAINER (filesel->dir_list), 5); gtk_container_border_width (GTK_CONTAINER (filesel->dir_list), 5);
...@@ -455,9 +440,6 @@ gtk_file_selection_init (GtkFileSelection *filesel) ...@@ -455,9 +440,6 @@ gtk_file_selection_init (GtkFileSelection *filesel)
gtk_signal_connect (GTK_OBJECT (filesel->file_list), "select_row", gtk_signal_connect (GTK_OBJECT (filesel->file_list), "select_row",
(GtkSignalFunc) gtk_file_selection_file_button, (GtkSignalFunc) gtk_file_selection_file_button,
(gpointer) filesel); (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_set_policy (GTK_CLIST (filesel->file_list), GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
gtk_clist_column_titles_passive (GTK_CLIST (filesel->file_list)); gtk_clist_column_titles_passive (GTK_CLIST (filesel->file_list));
gtk_container_border_width (GTK_CONTAINER (filesel->file_list), 5); gtk_container_border_width (GTK_CONTAINER (filesel->file_list), 5);
...@@ -1110,32 +1092,10 @@ gtk_file_selection_update_history_menu (GtkFileSelection *fs, ...@@ -1110,32 +1092,10 @@ gtk_file_selection_update_history_menu (GtkFileSelection *fs,
static void static void
gtk_file_selection_file_button (GtkWidget *widget, gtk_file_selection_file_button (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
gint button, GdkEventButton *bevent,
gpointer user_data) 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);
if (filename)
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; GtkFileSelection *fs = NULL;
gchar *filename; gchar *filename;
...@@ -1148,15 +1108,29 @@ gtk_file_selection_file_button_double (GtkWidget *widget, ...@@ -1148,15 +1108,29 @@ gtk_file_selection_file_button_double (GtkWidget *widget,
filename = gtk_clist_get_row_data (GTK_CLIST (fs->file_list), row); filename = gtk_clist_get_row_data (GTK_CLIST (fs->file_list), row);
if (filename) if (bevent && filename)
gtk_button_clicked (GTK_BUTTON (fs->ok_button)); {
switch (bevent->type)
{
case GDK_BUTTON_PRESS:
gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
break;
case GDK_2BUTTON_PRESS:
gtk_button_clicked (GTK_BUTTON (fs->ok_button));
break;
default:
break;
}
}
} }
static void static void
gtk_file_selection_dir_button (GtkWidget *widget, gtk_file_selection_dir_button (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
gint button, GdkEventButton *bevent,
gpointer user_data) gpointer user_data)
{ {
GtkFileSelection *fs = NULL; GtkFileSelection *fs = NULL;
...@@ -1170,30 +1144,22 @@ gtk_file_selection_dir_button (GtkWidget *widget, ...@@ -1170,30 +1144,22 @@ gtk_file_selection_dir_button (GtkWidget *widget,
filename = gtk_clist_get_row_data (GTK_CLIST (fs->dir_list), row); filename = gtk_clist_get_row_data (GTK_CLIST (fs->dir_list), row);
if (filename) if (bevent && 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;
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);
if (filename) switch (bevent->type)
gtk_file_selection_populate (fs, filename, FALSE); {
case GDK_BUTTON_PRESS:
gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
break;
case GDK_2BUTTON_PRESS:
gtk_file_selection_populate (fs, filename, FALSE);
break;
default:
break;
}
}
} }
static void static void
......
...@@ -1659,31 +1659,11 @@ hide_titles_clist (GtkWidget *widget, gpointer data) ...@@ -1659,31 +1659,11 @@ hide_titles_clist (GtkWidget *widget, gpointer data)
gtk_clist_column_titles_hide (GTK_CLIST (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 void
select_clist (GtkWidget *widget, select_clist (GtkWidget *widget,
gint row, gint row,
gint column, gint column,
gint button) GdkEventButton * bevent)
{ {
gint i; gint i;
guint8 spacing; guint8 spacing;
...@@ -1692,7 +1672,7 @@ select_clist (GtkWidget *widget, ...@@ -1692,7 +1672,7 @@ select_clist (GtkWidget *widget,
GdkBitmap *mask; GdkBitmap *mask;
g_print ("GtkCList Selection: row %d column %d button %d\n", 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++)