Mercurial > pidgin
changeset 13467:16544c190fe6
[gaim-migrate @ 15842]
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.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 08 Mar 2006 21:31:10 +0000 |
parents | d7b01bcfb031 |
children | e4aa2648ca28 |
files | src/gtkwhiteboard.c |
diffstat | 1 files changed, 35 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkwhiteboard.c Wed Mar 08 21:29:51 2006 +0000 +++ b/src/gtkwhiteboard.c Wed Mar 08 21:31:10 2006 +0000 @@ -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 @@ 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 @@ 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 @@ 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_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 @@ 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; - - if(gtkwb->window && gtkwb->pixmap) - { - LocalShutdownRequest = TRUE; + g_return_if_fail(wb != NULL); - gaim_gtk_whiteboard_destroy(wb); - } - else - LocalShutdownRequest = FALSE; + gaim_whiteboard_destroy(wb); - g_free(gtkwb); - wb->ui_data = NULL; - - /* Destroy whiteboard core, if the local user exited the whiteboard window */ - if(wb && LocalShutdownRequest) - { - gaim_whiteboard_destroy(wb); - } + return FALSE; } /* @@ -325,7 +315,7 @@ * 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 @@ /* 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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /* 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_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 @@ 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 @@ 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 @@ 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 @@ 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_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb) +static void gaim_gtk_whiteboard_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb) { GdkPixbuf *pixbuf; @@ -831,7 +824,7 @@ 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;