Commit 9ad92229 authored by Jay Painter's avatar Jay Painter

A couple of compiler warning fixes, GtkCList signal changes, changed

fileselect to work with new CList signals, and enhanced testgtk's clist
example to show pixmaps and signal results. -Jay Painter
parent 7e3692b9
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
Wed Feb 18 01:09:56 PST 1998 Jay Painter <jpaint@serv.net>
* gdk/gdk.c: fixed ambigous else compiler warning
* gtk/gtkgamma.c: fixed ambigous else compiler warning
* gtk/gtkclist.h:
* gtk/gtkclist.c: new signals which break everything! (yeah!)
* gtk/gtkfilesel.c: fixed to use new clist signals
Wed Feb 18 04:38:24 1998 Tim Janik <timj@gimp.org>
* gtk/gtkwidget.h:
......
......@@ -1282,21 +1282,23 @@ gdk_pointer_grab (GdkWindow * window,
confine_to,
time);
else
return_val = Success;;
return_val = Success;
if (return_val == Success)
if (!window_private->destroyed)
return_val = XGrabPointer (window_private->xdisplay,
xwindow,
owner_events,
xevent_mask,
GrabModeAsync, GrabModeAsync,
xconfine_to,
xcursor,
time);
else
return_val = AlreadyGrabbed;
{
if (!window_private->destroyed)
return_val = XGrabPointer (window_private->xdisplay,
xwindow,
owner_events,
xevent_mask,
GrabModeAsync, GrabModeAsync,
xconfine_to,
xcursor,
time);
else
return_val = AlreadyGrabbed;
}
if (return_val == GrabSuccess)
xgrab_window = window_private;
......
......@@ -1282,21 +1282,23 @@ gdk_pointer_grab (GdkWindow * window,
confine_to,
time);
else
return_val = Success;;
return_val = Success;
if (return_val == Success)
if (!window_private->destroyed)
return_val = XGrabPointer (window_private->xdisplay,
xwindow,
owner_events,
xevent_mask,
GrabModeAsync, GrabModeAsync,
xconfine_to,
xcursor,
time);
else
return_val = AlreadyGrabbed;
{
if (!window_private->destroyed)
return_val = XGrabPointer (window_private->xdisplay,
xwindow,
owner_events,
xevent_mask,
GrabModeAsync, GrabModeAsync,
xconfine_to,
xcursor,
time);
else
return_val = AlreadyGrabbed;
}
if (return_val == GrabSuccess)
xgrab_window = window_private;
......
......@@ -92,10 +92,11 @@ 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,
......@@ -105,7 +106,7 @@ enum
typedef void (*GtkCListSignal1) (GtkObject * object,
gint arg1,
gint arg2,
GdkEventButton * arg3,
gint arg3,
gpointer data);
typedef void (*GtkCListSignal2) (GtkObject * object,
......@@ -164,11 +165,11 @@ static void size_allocate_columns (GtkCList * clist);
static void real_select_row (GtkCList * clist,
gint row,
gint column,
GdkEventButton * event);
gint button);
static void real_unselect_row (GtkCList * clist,
gint row,
gint column,
GdkEventButton * event);
gint button);
static gint get_selection_info (GtkCList * clist,
gint x,
gint y,
......@@ -248,13 +249,11 @@ 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 ()
{
......@@ -291,21 +290,34 @@ 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_POINTER);
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT);
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_POINTER);
GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT);
clist_signals[CLICK_COLUMN] =
gtk_signal_new ("click_column",
GTK_RUN_LAST,
......@@ -335,6 +347,8 @@ 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;
......@@ -352,9 +366,10 @@ 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_POINTER (args[2]),
GTK_VALUE_INT (args[2]),
func_data);
}
......@@ -368,7 +383,8 @@ 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);
}
......@@ -812,7 +828,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;
}
......@@ -1425,7 +1441,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, NULL);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW], row, column, 0);
}
void
......@@ -1441,7 +1457,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, NULL);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], row, column, 0);
}
gint
......@@ -1904,8 +1920,25 @@ gtk_clist_button_press (GtkWidget * widget,
y = event->y;
if (get_selection_info (clist, x, y, &row, &column))
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
row, column, event);
{
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;
}
}
return FALSE;
}
......@@ -2724,7 +2757,7 @@ static void
real_select_row (GtkCList * clist,
gint row,
gint column,
GdkEventButton * event)
gint button)
{
gint i;
GList *list;
......@@ -2763,7 +2796,7 @@ real_select_row (GtkCList * clist,
}
else if (clist_row->state == GTK_STATE_SELECTED)
{
gtk_clist_unselect_row (clist, i, column);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], i, column, button);
}
i++;
......@@ -2791,7 +2824,7 @@ real_select_row (GtkCList * clist,
}
else if (clist_row->state == GTK_STATE_SELECTED)
{
gtk_clist_unselect_row (clist, i, column);
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW], i, column, button);
}
i++;
......@@ -2811,7 +2844,7 @@ 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, button);
}
else
{
......@@ -2839,7 +2872,7 @@ static void
real_unselect_row (GtkCList * clist,
gint row,
gint column,
GdkEventButton * event)
gint button)
{
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,14 +153,26 @@ 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,
GdkEventButton * event);
gint button);
void (*unselect_row) (GtkCList * clist,
gint row,
gint column,
GdkEventButton * event);
gint button);
void (*click_column) (GtkCList * clist,
gint column);
......
......@@ -286,15 +286,27 @@ static gint gtk_file_selection_key_press (GtkWidget *widget,
static void gtk_file_selection_file_button (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *bevent,
gint button,
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,
gint row,
gint column,
GdkEventButton *bevent,
gint button,
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,
gchar *rel_path,
gint try_complete);
......@@ -428,6 +440,9 @@ 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);
......@@ -440,6 +455,9 @@ 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);
......@@ -1092,10 +1110,10 @@ gtk_file_selection_update_history_menu (GtkFileSelection *fs,
static void
gtk_file_selection_file_button (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *bevent,
gpointer user_data)
gint row,
gint column,
gint button,
gpointer user_data)
{
GtkFileSelection *fs = NULL;
gchar *filename;
......@@ -1108,29 +1126,37 @@ gtk_file_selection_file_button (GtkWidget *widget,
filename = gtk_clist_get_row_data (GTK_CLIST (fs->file_list), row);
if (bevent && filename)
{
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;
}
}
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;
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_button_clicked (GTK_BUTTON (fs->ok_button));
}
static void
gtk_file_selection_dir_button (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *bevent,
gint button,
gpointer user_data)
{
GtkFileSelection *fs = NULL;
......@@ -1144,22 +1170,30 @@ gtk_file_selection_dir_button (GtkWidget *widget,
filename = gtk_clist_get_row_data (GTK_CLIST (fs->dir_list), row);
if (bevent && filename) {
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;
switch (bevent->type)
{
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;
}
}
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)
gtk_file_selection_populate (fs, filename, FALSE);
}
static void
......
......@@ -320,54 +320,58 @@ button_clicked_callback (GtkWidget *w, gpointer data)
active = (long) gtk_object_get_data (GTK_OBJECT (w), "_GtkGammaCurveIndex");
if (active == 3)
/* set gamma */
if (c->gamma_dialog)
return;
else
{
GtkWidget *vbox, *hbox, *label, *button;
gchar buf[64];
c->gamma_dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (c->gamma_dialog), "Gamma");
vbox = GTK_DIALOG (c->gamma_dialog)->vbox;
hbox = gtk_hbox_new (/* homogeneous */ FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
gtk_widget_show (hbox);
label = gtk_label_new ("Gamma value");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2);
gtk_widget_show (label);
sprintf (buf, "%g", c->gamma);
c->gamma_text = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (c->gamma_text), buf);
gtk_box_pack_start (GTK_BOX (hbox), c->gamma_text, TRUE, TRUE, 2);
gtk_widget_show (c->gamma_text);
/* fill in action area: */
hbox = GTK_DIALOG (c->gamma_dialog)->action_area;
button = gtk_button_new_with_label ("OK");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gamma_ok_callback, c);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gamma_cancel_callback, c);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
gtk_widget_show (c->gamma_dialog);
}
{
/* set gamma */
if (c->gamma_dialog)
return;
else
{
GtkWidget *vbox, *hbox, *label, *button;
gchar buf[64];
c->gamma_dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (c->gamma_dialog), "Gamma");
vbox = GTK_DIALOG (c->gamma_dialog)->vbox;
hbox = gtk_hbox_new (/* homogeneous */ FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
gtk_widget_show (hbox);
label = gtk_label_new ("Gamma value");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2);
gtk_widget_show (label);
sprintf (buf, "%g", c->gamma);
c->gamma_text = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (c->gamma_text), buf);
gtk_box_pack_start (GTK_BOX (hbox), c->gamma_text, TRUE, TRUE, 2);
gtk_widget_show (c->gamma_text);
/* fill in action area: */
hbox = GTK_DIALOG (c->gamma_dialog)->action_area;
button = gtk_button_new_with_label ("OK");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gamma_ok_callback, c);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_grab_default (button);