# HG changeset patch # User zas_ # Date 1208727036 0 # Node ID a73cc0fa14d03367db38472f31b0024af76a5a70 # Parent d87de3a3eb3b9b80a00f558cd2fa0a811376fce3 Use explicit names for mouse buttons instead of numbers. MOUSE_BUTTON_LEFT = 1 MOUSE_BUTTON_MIDDLE = 2 MOUSE_BUTTON_RIGHT = 3 It makes the code easier to read. diff -r d87de3a3eb3b -r a73cc0fa14d0 src/collect-table.c --- a/src/collect-table.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/collect-table.c Sun Apr 20 21:30:36 2008 +0000 @@ -1427,7 +1427,7 @@ switch (bevent->button) { - case 1: + case MOUSE_BUTTON_LEFT: if (bevent->type == GDK_2BUTTON_PRESS) { if (info) @@ -1440,7 +1440,7 @@ gtk_widget_grab_focus(ct->listview); } break; - case 3: + case MOUSE_BUTTON_RIGHT: ct->popup = collection_table_popup_menu(ct, (info != NULL)); gtk_menu_popup(GTK_MENU(ct->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); break; @@ -1469,7 +1469,7 @@ collection_table_selection_remove(ct, ct->click_info, SELECTION_PRELIGHT, NULL); } - if (bevent->button == 1 && + if (bevent->button == MOUSE_BUTTON_LEFT && info && ct->click_info == info) { collection_table_set_focus(ct, info); @@ -1503,7 +1503,7 @@ } } } - else if (bevent->button == 2 && + else if (bevent->button == MOUSE_BUTTON_MIDDLE && info && ct->click_info == info) { collection_table_select_util(ct, info, !INFO_SELECTED(info)); diff -r d87de3a3eb3b -r a73cc0fa14d0 src/dupe.c --- a/src/dupe.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/dupe.c Sun Apr 20 21:30:36 2008 +0000 @@ -2289,7 +2289,7 @@ dw->click_item = di; - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_RIGHT) { /* right click menu */ GtkWidget *menu; @@ -2312,14 +2312,15 @@ if (!di) return FALSE; - if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) + if (bevent->button == MOUSE_BUTTON_LEFT && + bevent->type == GDK_2BUTTON_PRESS) { dupe_menu_view(dw, di, widget, FALSE); } - if (bevent->button == 2) return TRUE; - - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_MIDDLE) return TRUE; + + if (bevent->button == MOUSE_BUTTON_RIGHT) { if (!dupe_listview_item_is_selected(dw, di, widget)) { @@ -2337,7 +2338,8 @@ return TRUE; } - if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS && + if (bevent->button == MOUSE_BUTTON_LEFT && + bevent->type == GDK_BUTTON_PRESS && !(bevent->state & GDK_SHIFT_MASK ) && !(bevent->state & GDK_CONTROL_MASK ) && dupe_listview_item_is_selected(dw, di, widget)) @@ -2358,7 +2360,7 @@ GtkTreeIter iter; DupeItem *di = NULL; - if (bevent->button != 1 && bevent->button != 2) return TRUE; + if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE) return TRUE; store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); @@ -2371,7 +2373,7 @@ gtk_tree_path_free(tpath); } - if (bevent->button == 2) + if (bevent->button == MOUSE_BUTTON_MIDDLE) { if (di && dw->click_item == di) { diff -r d87de3a3eb3b -r a73cc0fa14d0 src/img-view.c --- a/src/img-view.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/img-view.c Sun Apr 20 21:30:36 2008 +0000 @@ -603,13 +603,13 @@ switch (button) { - case 1: + case MOUSE_BUTTON_LEFT: view_step_next(vw); break; - case 2: + case MOUSE_BUTTON_MIDDLE: view_step_prev(vw); break; - case 3: + case MOUSE_BUTTON_RIGHT: menu = view_popup_menu(vw); gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); break; diff -r d87de3a3eb3b -r a73cc0fa14d0 src/info.c --- a/src/info.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/info.c Sun Apr 20 21:30:36 2008 +0000 @@ -696,11 +696,11 @@ static void info_window_image_button_cb(ImageWindow *imd, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer data) { - if (button == 1) + if (button == MOUSE_BUTTON_LEFT) { info_window_next_cb(NULL, data); } - else if (button == 2 || button == 3) + else if (button == MOUSE_BUTTON_MIDDLE || button == MOUSE_BUTTON_RIGHT) { info_window_back_cb(NULL, data); } diff -r d87de3a3eb3b -r a73cc0fa14d0 src/layout_image.c --- a/src/layout_image.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/layout_image.c Sun Apr 20 21:30:36 2008 +0000 @@ -1544,13 +1544,13 @@ switch (button) { - case 1: + case MOUSE_BUTTON_LEFT: layout_image_next(lw); break; - case 2: + case MOUSE_BUTTON_MIDDLE: layout_image_prev(lw); break; - case 3: + case MOUSE_BUTTON_RIGHT: menu = layout_image_pop_menu(lw); if (imd == lw->image) { @@ -1669,7 +1669,7 @@ switch (button) { - case 3: + case MOUSE_BUTTON_RIGHT: menu = layout_image_pop_menu(lw); if (imd == lw->image) { diff -r d87de3a3eb3b -r a73cc0fa14d0 src/pan-view.c --- a/src/pan-view.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/pan-view.c Sun Apr 20 21:30:36 2008 +0000 @@ -2026,7 +2026,7 @@ } pi = pan_item_find_by_coord(pw, PAN_ITEM_BOX, rx, ry, "info"); - if (pi && event->button == 1) + if (pi && event->button == MOUSE_BUTTON_LEFT) { pan_info_update(pw, NULL); return; @@ -2037,7 +2037,7 @@ switch (event->button) { - case 1: + case MOUSE_BUTTON_LEFT: pan_info_update(pw, pi); if (!pi && pw->layout == PAN_LAYOUT_CALENDAR) @@ -2046,9 +2046,9 @@ pan_calendar_update(pw, pi); } break; - case 2: + case MOUSE_BUTTON_MIDDLE: break; - case 3: + case MOUSE_BUTTON_RIGHT: pan_info_update(pw, pi); menu = pan_popup_menu(pw); gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); diff -r d87de3a3eb3b -r a73cc0fa14d0 src/pixbuf-renderer.c --- a/src/pixbuf-renderer.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/pixbuf-renderer.c Sun Apr 20 21:30:36 2008 +0000 @@ -3593,7 +3593,7 @@ switch (bevent->button) { - case 1: + case MOUSE_BUTTON_LEFT: pr->in_drag = TRUE; pr->drag_last_x = bevent->x; pr->drag_last_y = bevent->y; @@ -3603,10 +3603,10 @@ NULL, NULL, bevent->time); gtk_grab_add(widget); break; - case 2: + case MOUSE_BUTTON_MIDDLE: pr->drag_moved = 0; break; - case 3: + case MOUSE_BUTTON_RIGHT: pr_clicked_signal(pr, bevent); break; default: @@ -3643,11 +3643,11 @@ if (pr->drag_moved < PR_DRAG_SCROLL_THRESHHOLD) { - if (bevent->button == 1 && (bevent->state & GDK_SHIFT_MASK)) + if (bevent->button == MOUSE_BUTTON_LEFT && (bevent->state & GDK_SHIFT_MASK)) { pr_scroller_start(pr, bevent->x, bevent->y); } - else if (bevent->button == 1 || bevent->button == 2) + else if (bevent->button == MOUSE_BUTTON_LEFT || bevent->button == MOUSE_BUTTON_MIDDLE) { pr_clicked_signal(pr, bevent); } diff -r d87de3a3eb3b -r a73cc0fa14d0 src/search.c --- a/src/search.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/search.c Sun Apr 20 21:30:36 2008 +0000 @@ -1045,7 +1045,7 @@ sd->click_fd = mfd ? mfd->fd : NULL; - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_RIGHT) { GtkWidget *menu; @@ -1055,14 +1055,14 @@ if (!mfd) return FALSE; - if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) + if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_2BUTTON_PRESS) { layout_image_set_fd(NULL, mfd->fd); } - if (bevent->button == 2) return TRUE; - - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_MIDDLE) return TRUE; + + if (bevent->button == MOUSE_BUTTON_RIGHT) { if (!search_result_row_selected(sd, mfd->fd)) { @@ -1079,7 +1079,7 @@ return TRUE; } - if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS && + if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_BUTTON_PRESS && !(bevent->state & GDK_SHIFT_MASK ) && !(bevent->state & GDK_CONTROL_MASK ) && search_result_row_selected(sd, mfd->fd)) @@ -1101,7 +1101,7 @@ MatchFileData *mfd = NULL; - if (bevent->button != 1 && bevent->button != 2) return TRUE; + if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE) return TRUE; store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); @@ -1114,7 +1114,7 @@ gtk_tree_path_free(tpath); } - if (bevent->button == 2) + if (bevent->button == MOUSE_BUTTON_MIDDLE) { if (mfd && sd->click_fd == mfd->fd) { diff -r d87de3a3eb3b -r a73cc0fa14d0 src/typedefs.h --- a/src/typedefs.h Sun Apr 20 20:35:26 2008 +0000 +++ b/src/typedefs.h Sun Apr 20 21:30:36 2008 +0000 @@ -14,6 +14,14 @@ #define TYPEDEFS_H typedef enum { + MOUSE_BUTTON_LEFT = 1, + MOUSE_BUTTON_MIDDLE = 2, + MOUSE_BUTTON_RIGHT = 3, + MOUSE_BUTTON_WHEEL_UP = 4, + MOUSE_BUTTON_WHEEL_DOWN = 5 +} MouseButton; + +typedef enum { DIRVIEW_LIST, DIRVIEW_TREE } DirViewType; diff -r d87de3a3eb3b -r a73cc0fa14d0 src/ui_bookmark.c --- a/src/ui_bookmark.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/ui_bookmark.c Sun Apr 20 21:30:36 2008 +0000 @@ -735,7 +735,7 @@ { BookMarkData *bm = data; - if (event->button != 3) return FALSE; + if (event->button != MOUSE_BUTTON_RIGHT) return FALSE; bookmark_menu_popup(bm, button, event->button, event->time, FALSE); diff -r d87de3a3eb3b -r a73cc0fa14d0 src/ui_misc.c --- a/src/ui_misc.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/ui_misc.c Sun Apr 20 21:30:36 2008 +0000 @@ -21,6 +21,7 @@ #include #include +#include "main.h" #include "ui_misc.h" #include "ui_bookmark.h" @@ -1249,7 +1250,7 @@ { SizerData *sd = data; - if (bevent->button != 1) return FALSE; + if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE; sd->in_drag = TRUE; sd->press_x = bevent->x_root; @@ -1270,7 +1271,7 @@ { SizerData *sd = data; - if (bevent->button != 1) return FALSE; + if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE; if (gdk_pointer_is_grabbed() && GTK_WIDGET_HAS_GRAB(sd->sizer)) { diff -r d87de3a3eb3b -r a73cc0fa14d0 src/ui_pathsel.c --- a/src/ui_pathsel.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/ui_pathsel.c Sun Apr 20 21:30:36 2008 +0000 @@ -669,7 +669,7 @@ GtkTreeIter iter; GtkTreeSelection *selection; - if (event->button != 3 || + if (event->button != MOUSE_BUTTON_RIGHT || !gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(view), event->x, event->y, &tpath, &column, &cell_x, &cell_y)) { diff -r d87de3a3eb3b -r a73cc0fa14d0 src/utilops.c --- a/src/utilops.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/utilops.c Sun Apr 20 21:30:36 2008 +0000 @@ -1721,11 +1721,11 @@ static void file_util_delete_multiple_review_button_cb(ImageWindow *imd, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer data) { - if (button == 1) + if (button == MOUSE_BUTTON_LEFT) { file_util_delete_multiple_review_next(NULL, data); } - else if (button == 2 || button == 3) + else if (button == MOUSE_BUTTON_MIDDLE || button == MOUSE_BUTTON_RIGHT) { file_util_delete_multiple_review_back(NULL, data); } diff -r d87de3a3eb3b -r a73cc0fa14d0 src/view_dir.c --- a/src/view_dir.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/view_dir.c Sun Apr 20 21:30:36 2008 +0000 @@ -929,7 +929,7 @@ if (!vd->click_fd) return FALSE; vd_color_set(vd, vd->click_fd, FALSE); - if (bevent->button != 1) return TRUE; + if (bevent->button != MOUSE_BUTTON_LEFT) return TRUE; if ((bevent->x != 0 || bevent->y != 0) && gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, diff -r d87de3a3eb3b -r a73cc0fa14d0 src/view_dir_list.c --- a/src/view_dir_list.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/view_dir_list.c Sun Apr 20 21:30:36 2008 +0000 @@ -337,7 +337,7 @@ vd->click_fd = fd; vd_color_set(vd, vd->click_fd, TRUE); - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_RIGHT) { vd->popup = vd_pop_menu(vd, vd->click_fd); gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, diff -r d87de3a3eb3b -r a73cc0fa14d0 src/view_dir_tree.c --- a/src/view_dir_tree.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/view_dir_tree.c Sun Apr 20 21:30:36 2008 +0000 @@ -832,7 +832,7 @@ /* clicking this region should automatically reveal an expander, if necessary * treeview bug: the expander will not expand until a button_motion_event highlights it. */ - if (bevent->button == 1 && + if (bevent->button == MOUSE_BUTTON_LEFT && !left_of_expander && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath)) { @@ -850,14 +850,14 @@ vd->click_fd = (nd) ? nd->fd : NULL; vd_color_set(vd, vd->click_fd, TRUE); - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_RIGHT) { vd->popup = vd_pop_menu(vd, vd->click_fd); gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); } - return (bevent->button != 1); + return (bevent->button != MOUSE_BUTTON_LEFT); } static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data) diff -r d87de3a3eb3b -r a73cc0fa14d0 src/view_file_icon.c --- a/src/view_file_icon.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/view_file_icon.c Sun Apr 20 21:30:36 2008 +0000 @@ -1450,7 +1450,7 @@ switch (bevent->button) { - case 1: + case MOUSE_BUTTON_LEFT: if (!GTK_WIDGET_HAS_FOCUS(vfi->listview)) { gtk_widget_grab_focus(vfi->listview); @@ -1464,7 +1464,7 @@ } #endif break; - case 3: + case MOUSE_BUTTON_RIGHT: vfi->popup = vficon_pop_menu(vfi, (id != NULL)); gtk_menu_popup(GTK_MENU(vfi->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); break; @@ -1496,7 +1496,7 @@ if (id) was_selected = (id->selected & SELECTION_SELECTED); - if (bevent->button == 1 && + if (bevent->button == MOUSE_BUTTON_LEFT && id && vfi->click_id == id) { vficon_set_focus(vfi, id); @@ -1531,7 +1531,7 @@ } } } - else if (bevent->button == 2 && + else if (bevent->button == MOUSE_BUTTON_MIDDLE && id && vfi->click_id == id) { vficon_select_util(vfi, id, !(id->selected & SELECTION_SELECTED)); diff -r d87de3a3eb3b -r a73cc0fa14d0 src/view_file_list.c --- a/src/view_file_list.c Sun Apr 20 20:35:26 2008 +0000 +++ b/src/view_file_list.c Sun Apr 20 21:30:36 2008 +0000 @@ -715,7 +715,7 @@ GtkTreeModel *store; col_idx = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), "column_store_idx")); - if (bevent->button == 1 && + if (bevent->button == MOUSE_BUTTON_LEFT && col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST) return FALSE; @@ -731,7 +731,7 @@ vfl->click_fd = fd; - if (bevent->button == 3) + if (bevent->button == MOUSE_BUTTON_RIGHT) { vfl->popup = vflist_pop_menu(vfl, vfl->click_fd, col_idx); gtk_menu_popup(GTK_MENU(vfl->popup), NULL, NULL, NULL, NULL, @@ -741,7 +741,7 @@ if (!fd) return FALSE; - if (bevent->button == 2) + if (bevent->button == MOUSE_BUTTON_MIDDLE) { if (!vflist_row_is_selected(vfl, fd)) { @@ -751,7 +751,7 @@ } - if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS && + if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_BUTTON_PRESS && !(bevent->state & GDK_SHIFT_MASK ) && !(bevent->state & GDK_CONTROL_MASK ) && vflist_row_is_selected(vfl, fd)) @@ -761,7 +761,7 @@ } #if 0 - if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) + if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_2BUTTON_PRESS) { if (vfl->layout) layout_image_full_screen_start(vfl->layout); } @@ -777,12 +777,12 @@ GtkTreeIter iter; FileData *fd = NULL; - if (bevent->button == 2) + if (bevent->button == MOUSE_BUTTON_MIDDLE) { vflist_color_set(vfl, vfl->click_fd, FALSE); } - if (bevent->button != 1 && bevent->button != 2) + if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE) { return TRUE; } @@ -799,7 +799,7 @@ gtk_tree_path_free(tpath); } - if (bevent->button == 2) + if (bevent->button == MOUSE_BUTTON_MIDDLE) { if (fd && vfl->click_fd == fd) {