From: Richard L. <rl...@us...> - 2006-03-08 21:31:13
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26108 Modified Files: gtkwhiteboard.c Log Message: Clean up the destroy code, fixing CID 66 for real, I hope. Also, mark all the functions as static. They were marked static in the prototypes, but I don't know if that actually makes them static. Index: gtkwhiteboard.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkwhiteboard.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -p -r1.13 -r1.14 --- gtkwhiteboard.c 6 Mar 2006 21:40:22 -0000 1.13 +++ gtkwhiteboard.c 8 Mar 2006 21:31:10 -0000 1.14 @@ -34,7 +34,7 @@ static void gaim_gtk_whiteboard_create(GaimWhiteboard *wb); static void gaim_gtk_whiteboard_destroy(GaimWhiteboard *wb); -static void gaim_gtk_whiteboard_exit(GtkWidget *widget, gpointer data); +static gboolean whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, GaimGtkWhiteboard *gtkwb); /*static void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data); */ @@ -71,8 +71,6 @@ GList *buttonList = NULL; GdkColor DefaultColor[PALETTE_NUM_COLORS]; */ -static gboolean LocalShutdownRequest; - static int LastX; /* Tracks last position of the mouse when drawing */ static int LastY; static int MotionCount; /* Tracks how many brush motions made */ @@ -97,7 +95,7 @@ GaimWhiteboardUiOps *gaim_gtk_whiteboard return &ui_ops; } -void gaim_gtk_whiteboard_create(GaimWhiteboard *wb) +static void gaim_gtk_whiteboard_create(GaimWhiteboard *wb) { GtkWidget *window; GtkWidget *drawing_area; @@ -156,8 +154,8 @@ void gaim_gtk_whiteboard_create(GaimWhit gtk_window_set_resizable((GtkWindow*)(window), FALSE); - g_signal_connect(G_OBJECT(window), "destroy", - G_CALLBACK(gaim_gtk_whiteboard_exit), gtkwb); + g_signal_connect(G_OBJECT(window), "delete_event", + G_CALLBACK(whiteboard_close_cb), gtkwb); #if 0 int i; @@ -273,9 +271,13 @@ void gaim_gtk_whiteboard_create(GaimWhit */ } -void gaim_gtk_whiteboard_destroy(GaimWhiteboard *wb) +static void gaim_gtk_whiteboard_destroy(GaimWhiteboard *wb) { - GaimGtkWhiteboard *gtkwb = wb->ui_data; + GaimGtkWhiteboard *gtkwb; + + g_return_if_fail(wb != NULL); + gtkwb = wb->ui_data; + g_return_if_fail(gtkwb != NULL); /* TODO Ask if user wants to save picture before the session is closed */ @@ -291,33 +293,21 @@ void gaim_gtk_whiteboard_destroy(GaimWhi gtk_widget_destroy(gtkwb->window); gtkwb->window = NULL; } + g_free(gtkwb); + wb->ui_data = NULL; } -void gaim_gtk_whiteboard_exit(GtkWidget *widget, gpointer data) +static gboolean whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, GaimGtkWhiteboard *gtkwb) { - GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; GaimWhiteboard *wb; g_return_if_fail(gtkwb != NULL); wb = gtkwb->wb; + g_return_if_fail(wb != NULL); - if(gtkwb->window && gtkwb->pixmap) - { - LocalShutdownRequest = TRUE; - - gaim_gtk_whiteboard_destroy(wb); - } - else - LocalShutdownRequest = FALSE; - - g_free(gtkwb); - wb->ui_data = NULL; + gaim_whiteboard_destroy(wb); - /* Destroy whiteboard core, if the local user exited the whiteboard window */ - if(wb && LocalShutdownRequest) - { - gaim_whiteboard_destroy(wb); - } + return FALSE; } /* @@ -325,7 +315,7 @@ void gaim_gtk_whiteboard_exit(GtkWidget * and use new prpl_info member?) */ #if 0 -void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data) +static void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data) { GaimConversation *conv = data; GaimAccount *account = gaim_conversation_get_account(conv); @@ -340,7 +330,10 @@ void gaim_gtkwhiteboard_button_start_pre /* Write a local message to this conversation showing that a request for a * Doodle session has been made */ - gaim_conv_im_write(GAIM_CONV_IM(conv), "", _("Sent Doodle request."), + /* XXXX because otherwise gettext will see this string, even though it's + * in an #if 0 block. Remove the XXXX if you want to use this code. + * But, it really shouldn't be a Yahoo-specific string. ;) */ + gaim_conv_im_write(GAIM_CONV_IM(conv), "", XXXX_("Sent Doodle request."), GAIM_MESSAGE_NICK | GAIM_MESSAGE_RECV, time(NULL)); yahoo_doodle_command_send_request(gc, to); @@ -353,7 +346,7 @@ void gaim_gtkwhiteboard_button_start_pre } #endif -gboolean gaim_gtk_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) +static gboolean gaim_gtk_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; @@ -379,7 +372,7 @@ gboolean gaim_gtk_whiteboard_configure_e return TRUE; } -gboolean gaim_gtk_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) +static gboolean gaim_gtk_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); GdkPixmap *pixmap = gtkwb->pixmap; @@ -394,7 +387,7 @@ gboolean gaim_gtk_whiteboard_expose_even return FALSE; } -gboolean gaim_gtk_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data) +static gboolean gaim_gtk_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data) { GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; GdkPixmap *pixmap = gtkwb->pixmap; @@ -440,7 +433,7 @@ gboolean gaim_gtk_whiteboard_brush_down( return TRUE; } -gboolean gaim_gtk_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data) +static gboolean gaim_gtk_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data) { int x; int y; @@ -527,7 +520,7 @@ gboolean gaim_gtk_whiteboard_brush_motio return TRUE; } -gboolean gaim_gtk_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) +static gboolean gaim_gtk_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) { GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; GdkPixmap *pixmap = gtkwb->pixmap; @@ -583,7 +576,7 @@ gboolean gaim_gtk_whiteboard_brush_up(Gt return TRUE; } -void gaim_gtk_whiteboard_draw_brush_point(GaimWhiteboard *wb, int x, int y, int color, int size) +static void gaim_gtk_whiteboard_draw_brush_point(GaimWhiteboard *wb, int x, int y, int color, int size) { GaimGtkWhiteboard *gtkwb = wb->ui_data; GtkWidget *widget = gtkwb->drawing_area; @@ -636,7 +629,7 @@ void gaim_gtk_whiteboard_draw_brush_poin } /* Uses Bresenham's algorithm (as provided by Wikipedia) */ -void gaim_gtk_whiteboard_draw_brush_line(GaimWhiteboard *wb, int x0, int y0, int x1, int y1, int color, int size) +static void gaim_gtk_whiteboard_draw_brush_line(GaimWhiteboard *wb, int x0, int y0, int x1, int y1, int color, int size) { int temp; @@ -702,7 +695,7 @@ void gaim_gtk_whiteboard_draw_brush_line } } -void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height) +static void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height) { GaimGtkWhiteboard *gtkwb = wb->ui_data; @@ -710,7 +703,7 @@ void gaim_gtk_whiteboard_set_dimensions( gtkwb->height = height; } -void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color) +static void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color) { GaimGtkWhiteboard *gtkwb = wb->ui_data; @@ -718,7 +711,7 @@ void gaim_gtk_whiteboard_set_brush(GaimW gtkwb->brush_color = color; } -void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb) +static void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb) { GaimGtkWhiteboard *gtkwb = wb->ui_data; GdkPixmap *pixmap = gtkwb->pixmap; @@ -737,7 +730,7 @@ void gaim_gtk_whiteboard_clear(GaimWhite drawing_area->allocation.height); } -void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) +static void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) { GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); @@ -749,7 +742,7 @@ void gaim_gtk_whiteboard_button_clear_pr gaim_whiteboard_send_clear(gtkwb->wb); } -void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data) +static void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data) { GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); GdkPixbuf *pixbuf; @@ -816,7 +809,7 @@ void gaim_gtk_whiteboard_button_save_pre } } -void gaim_gtk_whiteboard_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb) +static void gaim_gtk_whiteboard_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb) { GdkPixbuf *pixbuf; @@ -831,7 +824,7 @@ void gaim_gtk_whiteboard_set_canvas_as_i gtk_window_set_icon((GtkWindow*)(gtkwb->window), pixbuf); } -void gaim_gtk_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color) +static void gaim_gtk_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color) { color->red = (color_rgb >> 8) | 0xFF; color->green = (color_rgb & 0xFF00) | 0xFF; |