Mercurial > audlegacy
comparison src/audacious/ui_playlist.c @ 3271:5f40f7d2887f trunk
better way to show fileinfopopup
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Wed, 08 Aug 2007 14:49:47 +0200 |
parents | 2d43219d2799 |
children | f985357757e0 |
comparison
equal
deleted
inserted
replaced
3270:30ed2878807f | 3271:5f40f7d2887f |
---|---|
48 #include "playlist_container.h" | 48 #include "playlist_container.h" |
49 #include "ui_playlist_manager.h" | 49 #include "ui_playlist_manager.h" |
50 #include "strings.h" | 50 #include "strings.h" |
51 #include "ui_equalizer.h" | 51 #include "ui_equalizer.h" |
52 #include "ui_fileopener.h" | 52 #include "ui_fileopener.h" |
53 #include "ui_fileinfopopup.h" | |
54 #include "ui_main.h" | 53 #include "ui_main.h" |
55 #include "ui_manager.h" | 54 #include "ui_manager.h" |
56 #include "util.h" | 55 #include "util.h" |
57 | 56 |
58 #include "ui_skinned_window.h" | 57 #include "ui_skinned_window.h" |
72 GtkWidget *playlistwin_shade, *playlistwin_close; | 71 GtkWidget *playlistwin_shade, *playlistwin_close; |
73 | 72 |
74 static GdkBitmap *playlistwin_mask = NULL; | 73 static GdkBitmap *playlistwin_mask = NULL; |
75 | 74 |
76 static gboolean playlistwin_hint_flag = FALSE; | 75 static gboolean playlistwin_hint_flag = FALSE; |
77 | |
78 static GtkWidget *playlistwin_infopopup = NULL; | |
79 static guint playlistwin_infopopup_sid = 0; | |
80 | 76 |
81 static GtkWidget *playlistwin_slider = NULL; | 77 static GtkWidget *playlistwin_slider = NULL; |
82 static GtkWidget *playlistwin_time_min, *playlistwin_time_sec; | 78 static GtkWidget *playlistwin_time_min, *playlistwin_time_sec; |
83 static GtkWidget *playlistwin_info, *playlistwin_sinfo; | 79 static GtkWidget *playlistwin_info, *playlistwin_sinfo; |
84 static GtkWidget *playlistwin_srew, *playlistwin_splay; | 80 static GtkWidget *playlistwin_srew, *playlistwin_splay; |
88 | 84 |
89 void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , | 85 void playlistwin_select_search_cbt_cb( GtkWidget *called_cbt , |
90 gpointer other_cbt ); | 86 gpointer other_cbt ); |
91 static gboolean playlistwin_select_search_kp_cb( GtkWidget *entry , GdkEventKey *event , | 87 static gboolean playlistwin_select_search_kp_cb( GtkWidget *entry , GdkEventKey *event , |
92 gpointer searchdlg_win ); | 88 gpointer searchdlg_win ); |
93 | |
94 static gboolean playlistwin_fileinfopopup_probe(gpointer * filepopup_win); | |
95 | 89 |
96 static gboolean playlistwin_resizing = FALSE; | 90 static gboolean playlistwin_resizing = FALSE; |
97 static gint playlistwin_resize_x, playlistwin_resize_y; | 91 static gint playlistwin_resize_x, playlistwin_resize_y; |
98 | 92 |
99 gboolean | 93 gboolean |
1595 playlistwin_create_window(); | 1589 playlistwin_create_window(); |
1596 | 1590 |
1597 playlistwin_create_widgets(); | 1591 playlistwin_create_widgets(); |
1598 playlistwin_update_info(playlist_get_active()); | 1592 playlistwin_update_info(playlist_get_active()); |
1599 | 1593 |
1600 playlistwin_infopopup = audacious_fileinfopopup_create(); | |
1601 | |
1602 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), ui_manager_get_accel_group()); | 1594 gtk_window_add_accel_group(GTK_WINDOW(playlistwin), ui_manager_get_accel_group()); |
1603 } | 1595 } |
1604 | 1596 |
1605 | 1597 |
1606 void | 1598 void |
1614 UI_SKINNED_BUTTON(mainwin_pl)->inside = TRUE; | 1606 UI_SKINNED_BUTTON(mainwin_pl)->inside = TRUE; |
1615 gtk_widget_queue_draw(mainwin_pl); | 1607 gtk_widget_queue_draw(mainwin_pl); |
1616 | 1608 |
1617 playlistwin_set_toprow(0); | 1609 playlistwin_set_toprow(0); |
1618 playlist_check_pos_current(playlist_get_active()); | 1610 playlist_check_pos_current(playlist_get_active()); |
1619 | |
1620 if ( playlistwin_infopopup_sid == 0 ) | |
1621 playlistwin_infopopup_sid = g_timeout_add( | |
1622 50 , (GSourceFunc)playlistwin_fileinfopopup_probe , playlistwin_infopopup ); | |
1623 | 1611 |
1624 gtk_widget_show_all(playlistwin); | 1612 gtk_widget_show_all(playlistwin); |
1625 if (!cfg.playlist_shaded) | 1613 if (!cfg.playlist_shaded) |
1626 gtk_widget_hide(playlistwin_sinfo); | 1614 gtk_widget_hide(playlistwin_sinfo); |
1627 ui_skinned_textbox_set_text(playlistwin_info, " "); | 1615 ui_skinned_textbox_set_text(playlistwin_info, " "); |
1637 | 1625 |
1638 gtk_widget_hide(playlistwin); | 1626 gtk_widget_hide(playlistwin); |
1639 cfg.playlist_visible = FALSE; | 1627 cfg.playlist_visible = FALSE; |
1640 UI_SKINNED_BUTTON(mainwin_pl)->inside = FALSE; | 1628 UI_SKINNED_BUTTON(mainwin_pl)->inside = FALSE; |
1641 gtk_widget_queue_draw(mainwin_pl); | 1629 gtk_widget_queue_draw(mainwin_pl); |
1642 | |
1643 /* no point in probing for playlistwin_infopopup trigger when the playlistwin is hidden */ | |
1644 if ( playlistwin_infopopup_sid != 0 ) | |
1645 { | |
1646 g_source_remove( playlistwin_infopopup_sid ); | |
1647 playlistwin_infopopup_sid = 0; | |
1648 } | |
1649 | 1630 |
1650 if ( cfg.player_visible ) | 1631 if ( cfg.player_visible ) |
1651 { | 1632 { |
1652 gtk_window_present(GTK_WINDOW(mainwin)); | 1633 gtk_window_present(GTK_WINDOW(mainwin)); |
1653 gtk_widget_grab_focus(mainwin); | 1634 gtk_widget_grab_focus(mainwin); |
1973 return TRUE; | 1954 return TRUE; |
1974 default: | 1955 default: |
1975 return FALSE; | 1956 return FALSE; |
1976 } | 1957 } |
1977 } | 1958 } |
1978 | |
1979 | |
1980 /* fileinfopopup callback for playlistwin */ | |
1981 static gboolean | |
1982 playlistwin_fileinfopopup_probe(gpointer * filepopup_win) | |
1983 { | |
1984 gint x, y, pos; | |
1985 TitleInput *tuple; | |
1986 static gint prev_x = 0, prev_y = 0, ctr = 0, prev_pos = -1; | |
1987 static gint shaded_pos = -1, shaded_prev_pos = -1; | |
1988 gboolean skip = FALSE; | |
1989 GdkWindow *win; | |
1990 Playlist *playlist = playlist_get_active(); | |
1991 | |
1992 win = gdk_window_at_pointer(NULL, NULL); | |
1993 gdk_window_get_pointer(GDK_WINDOW(playlistwin->window), &x, &y, NULL); | |
1994 pos = ui_skinned_playlist_get_position(playlistwin_list, x - 12, y - 20); | |
1995 | |
1996 if (win == NULL | |
1997 || cfg.show_filepopup_for_tuple == FALSE | |
1998 || UI_SKINNED_PLAYLIST(playlistwin_list)->tooltips == FALSE | |
1999 || pos != prev_pos | |
2000 || win != playlistwin_list->window) | |
2001 { | |
2002 prev_pos = pos; | |
2003 ctr = 0; | |
2004 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2005 return TRUE; | |
2006 } | |
2007 | |
2008 if (prev_x == x && prev_y == y) | |
2009 ctr++; | |
2010 else | |
2011 { | |
2012 ctr = 0; | |
2013 prev_x = x; | |
2014 prev_y = y; | |
2015 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2016 return TRUE; | |
2017 } | |
2018 | |
2019 if (playlistwin_is_shaded()) | |
2020 { | |
2021 shaded_pos = playlist_get_position(playlist); | |
2022 if (shaded_prev_pos != shaded_pos) | |
2023 skip = TRUE; | |
2024 } | |
2025 | |
2026 if (ctr >= cfg.filepopup_delay && (skip == TRUE || GTK_WIDGET_VISIBLE(GTK_WIDGET(filepopup_win)) != TRUE)) { | |
2027 if (pos == -1 && !playlistwin_is_shaded()) | |
2028 { | |
2029 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2030 return TRUE; | |
2031 } | |
2032 /* shaded mode */ | |
2033 else | |
2034 { | |
2035 tuple = playlist_get_tuple(playlist, shaded_pos); | |
2036 audacious_fileinfopopup_hide(GTK_WIDGET(filepopup_win), NULL); | |
2037 audacious_fileinfopopup_show_from_tuple(GTK_WIDGET(filepopup_win), tuple); | |
2038 shaded_prev_pos = shaded_pos; | |
2039 } | |
2040 | |
2041 prev_pos = pos; | |
2042 | |
2043 tuple = playlist_get_tuple(playlist, pos); | |
2044 audacious_fileinfopopup_show_from_tuple(GTK_WIDGET(filepopup_win), tuple); | |
2045 } | |
2046 | |
2047 return TRUE; | |
2048 } |