aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorJan D2010-07-05 11:17:12 +0200
committerJan D2010-07-05 11:17:12 +0200
commite4c8d29a32adbde811a109d5e19caa75fd9d042b (patch)
treeffaa67180bd87eae947408a76cddecaaa1c227b0 /src/gtkutil.c
parent898b4c5c2cb4b4ae2fa2cd1631db63a9acff787a (diff)
downloademacs-e4c8d29a32adbde811a109d5e19caa75fd9d042b.tar.gz
emacs-e4c8d29a32adbde811a109d5e19caa75fd9d042b.zip
Fix some bad prototypes and formatting after conversion from K&R declaration.
* lwlib/lwlib-Xaw.c: Include <ctype.h> for isdigit. (fill_xft_data, set_text): Remove unused variable screen. (draw_text): Cast bp to FcChar8*. (find_xft_data): Return 0 if inst or xft_data is not set. (wm_delete_window): Correct prototype. Initialize widget to 0 and return if widget is still 0 after loop. * lwlib/xlwmenu.c (XlwMenuSetValues, XlwMenuInitialize): Correct prototype. (display_menu_item): Remove unused variable gi. (make_windows_if_needed): Remove unused variable screen. (XlwMenuRedisplay): Remove unused variable i. * src/gtkutil.c (xg_get_pixbuf_from_pix_and_mask) (xg_get_image_for_pixmap, create_dialog) (xg_get_file_with_selection, xg_get_file_name, update_cl_data) (menuitem_highlight_callback, make_menu_item) (xg_create_one_menuitem, create_menus, xg_update_menu_item) (xg_create_scroll_bar, xg_update_scrollbar_pos) (xg_set_toolkit_scroll_bar_thumb, xg_tool_bar_button_cb) (xg_tool_bar_proxy_help_callback, xg_tool_bar_detach_callback) (xg_tool_bar_attach_callback, xg_tool_bar_help_callback) (xg_tool_bar_item_expose_callback): Reformat prototype. (xg_update_menubar): GList *group => GSList *group. (xg_modify_menubar_widgets): Initialize witem to 0, check witem != 0 before use. (update_frame_tool_bar): 4:th param to xg_get_image_for_pixmap changed to GTK_IMAGE (wimage). * src/xsettings.c (something_changedCB, parse_settings) (apply_xft_settings): Reformat prototype. (something_changedCB, init_gconf): Remove unused variable i. (read_settings): Remove unused variable long_len. * src/xsmfns.c (SSDATA): New macro. (smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings passed to strlen/strcpy/strcat. (create_client_leader_window): Surround with #ifndef USE_GTK. Cast 7:th arg to XChangeProperty to (unsigned char *)
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c136
1 files changed, 90 insertions, 46 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 86bf03eed41..447d5642b79 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -231,7 +231,9 @@ xg_create_default_cursor (Display *dpy)
231/* Apply GMASK to GPIX and return a GdkPixbuf with an alpha channel. */ 231/* Apply GMASK to GPIX and return a GdkPixbuf with an alpha channel. */
232 232
233static GdkPixbuf * 233static GdkPixbuf *
234xg_get_pixbuf_from_pix_and_mask (GdkPixmap *gpix, GdkPixmap *gmask, GdkColormap *cmap) 234xg_get_pixbuf_from_pix_and_mask (GdkPixmap *gpix,
235 GdkPixmap *gmask,
236 GdkColormap *cmap)
235{ 237{
236 int width, height; 238 int width, height;
237 GdkPixbuf *icon_buf, *tmp_buf; 239 GdkPixbuf *icon_buf, *tmp_buf;
@@ -309,7 +311,10 @@ file_for_image (Lisp_Object image)
309 If OLD_WIDGET is not NULL, that widget is modified. */ 311 If OLD_WIDGET is not NULL, that widget is modified. */
310 312
311static GtkWidget * 313static GtkWidget *
312xg_get_image_for_pixmap (FRAME_PTR f, struct image *img, GtkWidget *widget, GtkImage *old_widget) 314xg_get_image_for_pixmap (FRAME_PTR f,
315 struct image *img,
316 GtkWidget *widget,
317 GtkImage *old_widget)
313{ 318{
314 GdkPixmap *gpix; 319 GdkPixmap *gpix;
315 GdkPixmap *gmask; 320 GdkPixmap *gmask;
@@ -1039,7 +1044,9 @@ dialog_delete_callback (GtkWidget *w, GdkEvent *event, gpointer user_data)
1039 Returns the GTK dialog widget. */ 1044 Returns the GTK dialog widget. */
1040 1045
1041static GtkWidget * 1046static GtkWidget *
1042create_dialog (widget_value *wv, GCallback select_cb, GCallback deactivate_cb) 1047create_dialog (widget_value *wv,
1048 GCallback select_cb,
1049 GCallback deactivate_cb)
1043{ 1050{
1044 char *title = get_dialog_title (wv->name[0]); 1051 char *title = get_dialog_title (wv->name[0]);
1045 int total_buttons = wv->name[1] - '0'; 1052 int total_buttons = wv->name[1] - '0';
@@ -1459,12 +1466,11 @@ xg_get_file_name_from_selector (GtkWidget *w)
1459 Returns the created widget. */ 1466 Returns the created widget. */
1460 1467
1461static GtkWidget * 1468static GtkWidget *
1462xg_get_file_with_selection ( 1469xg_get_file_with_selection (FRAME_PTR f,
1463 FRAME_PTR f, 1470 char *prompt,
1464 char *prompt, 1471 char *default_filename,
1465 char *default_filename, 1472 int mustmatch_p, int only_dir_p,
1466 int mustmatch_p, int only_dir_p, 1473 xg_get_file_func *func)
1467 xg_get_file_func *func)
1468{ 1474{
1469 GtkWidget *filewin; 1475 GtkWidget *filewin;
1470 GtkFileSelection *filesel; 1476 GtkFileSelection *filesel;
@@ -1502,7 +1508,11 @@ xg_get_file_with_selection (
1502 The returned string must be freed by the caller. */ 1508 The returned string must be freed by the caller. */
1503 1509
1504char * 1510char *
1505xg_get_file_name (FRAME_PTR f, char *prompt, char *default_filename, int mustmatch_p, int only_dir_p) 1511xg_get_file_name (FRAME_PTR f,
1512 char *prompt,
1513 char *default_filename,
1514 int mustmatch_p,
1515 int only_dir_p)
1506{ 1516{
1507 GtkWidget *w = 0; 1517 GtkWidget *w = 0;
1508 char *fn = 0; 1518 char *fn = 0;
@@ -1652,7 +1662,9 @@ make_cl_data (xg_menu_cb_data *cl_data, FRAME_PTR f, GCallback highlight_cb)
1652 creating the menu bar. */ 1662 creating the menu bar. */
1653 1663
1654static void 1664static void
1655update_cl_data (xg_menu_cb_data *cl_data, FRAME_PTR f, GCallback highlight_cb) 1665update_cl_data (xg_menu_cb_data *cl_data,
1666 FRAME_PTR f,
1667 GCallback highlight_cb)
1656{ 1668{
1657 if (cl_data) 1669 if (cl_data)
1658 { 1670 {
@@ -1723,7 +1735,9 @@ menuitem_destroy_callback (GtkWidget *w, gpointer client_data)
1723 Returns FALSE to tell GTK to keep processing this event. */ 1735 Returns FALSE to tell GTK to keep processing this event. */
1724 1736
1725static gboolean 1737static gboolean
1726menuitem_highlight_callback (GtkWidget *w, GdkEventCrossing *event, gpointer client_data) 1738menuitem_highlight_callback (GtkWidget *w,
1739 GdkEventCrossing *event,
1740 gpointer client_data)
1727{ 1741{
1728 GdkEvent ev; 1742 GdkEvent ev;
1729 GtkWidget *subwidget; 1743 GtkWidget *subwidget;
@@ -1800,7 +1814,10 @@ make_widget_for_menu_item (char *utf8_label, char *utf8_key)
1800 but the MacOS X version doesn't either, so I guess that is OK. */ 1814 but the MacOS X version doesn't either, so I guess that is OK. */
1801 1815
1802static GtkWidget * 1816static GtkWidget *
1803make_menu_item (char *utf8_label, char *utf8_key, widget_value *item, GSList **group) 1817make_menu_item (char *utf8_label,
1818 char *utf8_key,
1819 widget_value *item,
1820 GSList **group)
1804{ 1821{
1805 GtkWidget *w; 1822 GtkWidget *w;
1806 GtkWidget *wtoadd = 0; 1823 GtkWidget *wtoadd = 0;
@@ -1945,7 +1962,12 @@ tearoff_activate (GtkWidget *widget, gpointer client_data)
1945 Returns the created GtkWidget. */ 1962 Returns the created GtkWidget. */
1946 1963
1947static GtkWidget * 1964static GtkWidget *
1948xg_create_one_menuitem (widget_value *item, FRAME_PTR f, GCallback select_cb, GCallback highlight_cb, xg_menu_cb_data *cl_data, GSList **group) 1965xg_create_one_menuitem (widget_value *item,
1966 FRAME_PTR f,
1967 GCallback select_cb,
1968 GCallback highlight_cb,
1969 xg_menu_cb_data *cl_data,
1970 GSList **group)
1949{ 1971{
1950 char *utf8_label; 1972 char *utf8_label;
1951 char *utf8_key; 1973 char *utf8_key;
@@ -1988,10 +2010,6 @@ xg_create_one_menuitem (widget_value *item, FRAME_PTR f, GCallback select_cb, GC
1988 return w; 2010 return w;
1989} 2011}
1990 2012
1991static GtkWidget *create_menus (widget_value *, FRAME_PTR, GCallback,
1992 GCallback, GCallback, int, int, int,
1993 GtkWidget *, xg_menu_cb_data *, char *);
1994
1995/* Create a full menu tree specified by DATA. 2013/* Create a full menu tree specified by DATA.
1996 F is the frame the created menu belongs to. 2014 F is the frame the created menu belongs to.
1997 SELECT_CB is the callback to use when a menu item is selected. 2015 SELECT_CB is the callback to use when a menu item is selected.
@@ -2015,19 +2033,17 @@ static GtkWidget *create_menus (widget_value *, FRAME_PTR, GCallback,
2015 This function calls itself to create submenus. */ 2033 This function calls itself to create submenus. */
2016 2034
2017static GtkWidget * 2035static GtkWidget *
2018create_menus (data, f, select_cb, deactivate_cb, highlight_cb, 2036create_menus (widget_value *data,
2019 pop_up_p, menu_bar_p, add_tearoff_p, topmenu, cl_data, name) 2037 FRAME_PTR f,
2020 widget_value *data; 2038 GCallback select_cb,
2021 FRAME_PTR f; 2039 GCallback deactivate_cb,
2022 GCallback select_cb; 2040 GCallback highlight_cb,
2023 GCallback deactivate_cb; 2041 int pop_up_p,
2024 GCallback highlight_cb; 2042 int menu_bar_p,
2025 int pop_up_p; 2043 int add_tearoff_p,
2026 int menu_bar_p; 2044 GtkWidget *topmenu,
2027 int add_tearoff_p; 2045 xg_menu_cb_data *cl_data,
2028 GtkWidget *topmenu; 2046 char *name)
2029 xg_menu_cb_data *cl_data;
2030 char *name;
2031{ 2047{
2032 widget_value *item; 2048 widget_value *item;
2033 GtkWidget *wmenu = topmenu; 2049 GtkWidget *wmenu = topmenu;
@@ -2397,7 +2413,7 @@ xg_update_menubar (GtkWidget *menubar,
2397 Insert X. */ 2413 Insert X. */
2398 2414
2399 int nr = pos; 2415 int nr = pos;
2400 GList *group = 0; 2416 GSList *group = 0;
2401 GtkWidget *w = xg_create_one_menuitem (val, 2417 GtkWidget *w = xg_create_one_menuitem (val,
2402 f, 2418 f,
2403 select_cb, 2419 select_cb,
@@ -2456,7 +2472,11 @@ xg_update_menubar (GtkWidget *menubar,
2456 CL_DATA is the data to set in the widget for menu invocation. */ 2472 CL_DATA is the data to set in the widget for menu invocation. */
2457 2473
2458static void 2474static void
2459xg_update_menu_item (widget_value *val, GtkWidget *w, GCallback select_cb, GCallback highlight_cb, xg_menu_cb_data *cl_data) 2475xg_update_menu_item (widget_value *val,
2476 GtkWidget *w,
2477 GCallback select_cb,
2478 GCallback highlight_cb,
2479 xg_menu_cb_data *cl_data)
2460{ 2480{
2461 GtkWidget *wchild; 2481 GtkWidget *wchild;
2462 GtkLabel *wlbl = 0; 2482 GtkLabel *wlbl = 0;
@@ -2760,7 +2780,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p,
2760 GList *iter; 2780 GList *iter;
2761 GtkWidget *sub = 0; 2781 GtkWidget *sub = 0;
2762 GtkWidget *newsub; 2782 GtkWidget *newsub;
2763 GtkMenuItem *witem; 2783 GtkMenuItem *witem = 0;
2764 2784
2765 /* Find sub menu that corresponds to val and update it. */ 2785 /* Find sub menu that corresponds to val and update it. */
2766 for (iter = list ; iter; iter = g_list_next (iter)) 2786 for (iter = list ; iter; iter = g_list_next (iter))
@@ -2783,7 +2803,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p,
2783 /* sub may still be NULL. If we just updated non deep and added 2803 /* sub may still be NULL. If we just updated non deep and added
2784 a new menu bar item, it has no sub menu yet. So we set the 2804 a new menu bar item, it has no sub menu yet. So we set the
2785 newly created sub menu under witem. */ 2805 newly created sub menu under witem. */
2786 if (newsub != sub) 2806 if (newsub != sub && witem != 0)
2787 { 2807 {
2788 xg_set_screen (newsub, f); 2808 xg_set_screen (newsub, f);
2789 gtk_menu_item_set_submenu (witem, newsub); 2809 gtk_menu_item_set_submenu (witem, newsub);
@@ -2976,7 +2996,11 @@ xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data)
2976 to set resources for the widget. */ 2996 to set resources for the widget. */
2977 2997
2978void 2998void
2979xg_create_scroll_bar (FRAME_PTR f, struct scroll_bar *bar, GCallback scroll_callback, GCallback end_callback, char *scroll_bar_name) 2999xg_create_scroll_bar (FRAME_PTR f,
3000 struct scroll_bar *bar,
3001 GCallback scroll_callback,
3002 GCallback end_callback,
3003 char *scroll_bar_name)
2980{ 3004{
2981 GtkWidget *wscroll; 3005 GtkWidget *wscroll;
2982 GtkWidget *webox; 3006 GtkWidget *webox;
@@ -3047,7 +3071,12 @@ xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id)
3047 WIDTH, HEIGHT is the size in pixels the bar shall have. */ 3071 WIDTH, HEIGHT is the size in pixels the bar shall have. */
3048 3072
3049void 3073void
3050xg_update_scrollbar_pos (FRAME_PTR f, int scrollbar_id, int top, int left, int width, int height) 3074xg_update_scrollbar_pos (FRAME_PTR f,
3075 int scrollbar_id,
3076 int top,
3077 int left,
3078 int width,
3079 int height)
3051{ 3080{
3052 3081
3053 GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); 3082 GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id);
@@ -3108,7 +3137,10 @@ xg_update_scrollbar_pos (FRAME_PTR f, int scrollbar_id, int top, int left, int w
3108 displaying PORTION out of a whole WHOLE, and our position POSITION. */ 3137 displaying PORTION out of a whole WHOLE, and our position POSITION. */
3109 3138
3110void 3139void
3111xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole) 3140xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
3141 int portion,
3142 int position,
3143 int whole)
3112{ 3144{
3113 GtkWidget *wscroll = xg_get_widget_from_map (bar->x_window); 3145 GtkWidget *wscroll = xg_get_widget_from_map (bar->x_window);
3114 3146
@@ -3245,7 +3277,9 @@ xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event)
3245 tool bar. 0 is the first button. */ 3277 tool bar. 0 is the first button. */
3246 3278
3247static gboolean 3279static gboolean
3248xg_tool_bar_button_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) 3280xg_tool_bar_button_cb (GtkWidget *widget,
3281 GdkEventButton *event,
3282 gpointer user_data)
3249{ 3283{
3250 /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */ 3284 /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */
3251 gpointer ptr = (gpointer) (EMACS_INT) event->state; 3285 gpointer ptr = (gpointer) (EMACS_INT) event->state;
@@ -3326,7 +3360,9 @@ xg_tool_bar_help_callback (GtkWidget *w,
3326 the detached tool bar when the detached tool bar it is not expanded. */ 3360 the detached tool bar when the detached tool bar it is not expanded. */
3327 3361
3328static gboolean 3362static gboolean
3329xg_tool_bar_proxy_help_callback (GtkWidget *w, GdkEventCrossing *event, gpointer client_data) 3363xg_tool_bar_proxy_help_callback (GtkWidget *w,
3364 GdkEventCrossing *event,
3365 gpointer client_data)
3330{ 3366{
3331 GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w), 3367 GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w),
3332 XG_TOOL_BAR_PROXY_BUTTON)); 3368 XG_TOOL_BAR_PROXY_BUTTON));
@@ -3462,7 +3498,9 @@ xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
3462 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ 3498 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */
3463 3499
3464static void 3500static void
3465xg_tool_bar_detach_callback (GtkHandleBox *wbox, GtkWidget *w, gpointer client_data) 3501xg_tool_bar_detach_callback (GtkHandleBox *wbox,
3502 GtkWidget *w,
3503 gpointer client_data)
3466{ 3504{
3467 FRAME_PTR f = (FRAME_PTR) client_data; 3505 FRAME_PTR f = (FRAME_PTR) client_data;
3468 extern int x_gtk_whole_detached_tool_bar; 3506 extern int x_gtk_whole_detached_tool_bar;
@@ -3490,7 +3528,9 @@ xg_tool_bar_detach_callback (GtkHandleBox *wbox, GtkWidget *w, gpointer client_d
3490 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ 3528 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */
3491 3529
3492static void 3530static void
3493xg_tool_bar_attach_callback (GtkHandleBox *wbox, GtkWidget *w, gpointer client_data) 3531xg_tool_bar_attach_callback (GtkHandleBox *wbox,
3532 GtkWidget *w,
3533 gpointer client_data)
3494{ 3534{
3495 FRAME_PTR f = (FRAME_PTR) client_data; 3535 FRAME_PTR f = (FRAME_PTR) client_data;
3496 g_object_set (G_OBJECT (w), "show-arrow", TRUE, NULL); 3536 g_object_set (G_OBJECT (w), "show-arrow", TRUE, NULL);
@@ -3517,7 +3557,9 @@ xg_tool_bar_attach_callback (GtkHandleBox *wbox, GtkWidget *w, gpointer client_d
3517 Returns FALSE to tell GTK to keep processing this event. */ 3557 Returns FALSE to tell GTK to keep processing this event. */
3518 3558
3519static gboolean 3559static gboolean
3520xg_tool_bar_help_callback (GtkWidget *w, GdkEventCrossing *event, gpointer client_data) 3560xg_tool_bar_help_callback (GtkWidget *w,
3561 GdkEventCrossing *event,
3562 gpointer client_data)
3521{ 3563{
3522 /* The EMACS_INT cast avoids a warning. */ 3564 /* The EMACS_INT cast avoids a warning. */
3523 int idx = (int) (EMACS_INT) client_data; 3565 int idx = (int) (EMACS_INT) client_data;
@@ -3556,7 +3598,9 @@ xg_tool_bar_help_callback (GtkWidget *w, GdkEventCrossing *event, gpointer clien
3556 Returns FALSE to tell GTK to keep processing this event. */ 3598 Returns FALSE to tell GTK to keep processing this event. */
3557 3599
3558static gboolean 3600static gboolean
3559xg_tool_bar_item_expose_callback (GtkWidget *w, GdkEventExpose *event, gpointer client_data) 3601xg_tool_bar_item_expose_callback (GtkWidget *w,
3602 GdkEventExpose *event,
3603 gpointer client_data)
3560{ 3604{
3561 gint width, height; 3605 gint width, height;
3562 3606
@@ -3849,7 +3893,6 @@ update_frame_tool_bar (FRAME_PTR f)
3849 GtkWidget *wbutton = NULL; 3893 GtkWidget *wbutton = NULL;
3850 GtkWidget *weventbox; 3894 GtkWidget *weventbox;
3851 Lisp_Object specified_file; 3895 Lisp_Object specified_file;
3852 Lisp_Object lbl = PROP (TOOL_BAR_ITEM_LABEL);
3853 char *label = SSDATA (PROP (TOOL_BAR_ITEM_LABEL)); 3896 char *label = SSDATA (PROP (TOOL_BAR_ITEM_LABEL));
3854 3897
3855 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i); 3898 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i);
@@ -4020,7 +4063,8 @@ update_frame_tool_bar (FRAME_PTR f)
4020 } 4063 }
4021 else if (img && old_img != img->pixmap) 4064 else if (img && old_img != img->pixmap)
4022 { 4065 {
4023 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); 4066 (void) xg_get_image_for_pixmap (f, img, x->widget,
4067 GTK_IMAGE (wimage));
4024 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, 4068 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
4025 (gpointer)img->pixmap); 4069 (gpointer)img->pixmap);
4026 4070