Changes in util.c [9a7b4f2:c1f1e1e]
Legend:
- Unmodified
- Added
- Removed
-
util.c
r9a7b4f2 rc1f1e1e 8 8 #include <sys/types.h> 9 9 10 void sepbar(const char *in) 11 { 12 WINDOW *sepwin; 13 const owl_messagelist *ml; 14 const owl_view *v; 15 int x, y, i; 16 const char *foo, *appendtosepbar; 17 18 sepwin=owl_global_get_curs_sepwin(&g); 19 ml=owl_global_get_msglist(&g); 20 v=owl_global_get_current_view(&g); 21 22 werase(sepwin); 23 wattron(sepwin, A_REVERSE); 24 if (owl_global_is_fancylines(&g)) { 25 whline(sepwin, ACS_HLINE, owl_global_get_cols(&g)); 26 } else { 27 whline(sepwin, '-', owl_global_get_cols(&g)); 28 } 29 30 if (owl_global_is_sepbar_disable(&g)) { 31 getyx(sepwin, y, x); 32 wmove(sepwin, y, owl_global_get_cols(&g)-1); 33 return; 34 } 35 36 wmove(sepwin, 0, 2); 37 38 if (owl_messagelist_get_size(ml) == 0) 39 waddstr(sepwin, " (-/-) "); 40 else 41 wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1, 42 owl_view_get_size(v), 43 owl_messagelist_get_size(ml)); 44 45 foo=owl_view_get_filtname(v); 46 if (strcmp(foo, owl_global_get_view_home(&g))) 47 wattroff(sepwin, A_REVERSE); 48 wprintw(sepwin, " %s ", owl_view_get_filtname(v)); 49 if (strcmp(foo, owl_global_get_view_home(&g))) 50 wattron(sepwin, A_REVERSE); 51 52 if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { 53 getyx(sepwin, y, x); 54 wmove(sepwin, y, x+2); 55 wattron(sepwin, A_BOLD); 56 waddstr(sepwin, " <truncated> "); 57 wattroff(sepwin, A_BOLD); 58 } 59 60 i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); 61 if ((i != -1) && 62 (i < owl_view_get_size(v)-1)) { 63 getyx(sepwin, y, x); 64 wmove(sepwin, y, x+2); 65 wattron(sepwin, A_BOLD); 66 waddstr(sepwin, " <more> "); 67 wattroff(sepwin, A_BOLD); 68 } 69 70 if (owl_global_get_rightshift(&g)>0) { 71 getyx(sepwin, y, x); 72 wmove(sepwin, y, x+2); 73 wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g)); 74 } 75 76 if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { 77 getyx(sepwin, y, x); 78 wmove(sepwin, y, x+2); 79 wattron(sepwin, A_BOLD); 80 wattroff(sepwin, A_REVERSE); 81 if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { 82 waddstr(sepwin, " AWAY "); 83 } else if (owl_global_is_zaway(&g)) { 84 waddstr(sepwin, " Z-AWAY "); 85 } else if (owl_global_is_aaway(&g)) { 86 waddstr(sepwin, " A-AWAY "); 87 } 88 wattron(sepwin, A_REVERSE); 89 wattroff(sepwin, A_BOLD); 90 } 91 92 if (owl_global_get_curmsg_vert_offset(&g)) { 93 getyx(sepwin, y, x); 94 wmove(sepwin, y, x+2); 95 wattron(sepwin, A_BOLD); 96 wattroff(sepwin, A_REVERSE); 97 waddstr(sepwin, " SCROLL "); 98 wattron(sepwin, A_REVERSE); 99 wattroff(sepwin, A_BOLD); 100 } 101 102 if (in) { 103 getyx(sepwin, y, x); 104 wmove(sepwin, y, x+2); 105 waddstr(sepwin, in); 106 } 107 108 appendtosepbar = owl_global_get_appendtosepbar(&g); 109 if (appendtosepbar && *appendtosepbar) { 110 getyx(sepwin, y, x); 111 wmove(sepwin, y, x+2); 112 waddstr(sepwin, " "); 113 waddstr(sepwin, owl_global_get_appendtosepbar(&g)); 114 waddstr(sepwin, " "); 115 } 116 117 getyx(sepwin, y, x); 118 wmove(sepwin, y, owl_global_get_cols(&g)-1); 119 120 wattroff(sepwin, A_BOLD); 121 wattroff(sepwin, A_REVERSE); 122 } 10 #include <glib-object.h> 123 11 124 12 char **atokenize(const char *buffer, const char *sep, int *i) … … 786 674 return buf; 787 675 } 676 677 gulong owl_dirty_window_on_signal(owl_window *w, gpointer sender, const gchar *detailed_signal) 678 { 679 return owl_signal_connect_object(sender, detailed_signal, G_CALLBACK(owl_window_dirty), w, G_CONNECT_SWAPPED); 680 } 681 682 typedef struct { /*noproto*/ 683 GObject *sender; 684 gulong signal_id; 685 } SignalData; 686 687 static void _closure_invalidated(gpointer data, GClosure *closure); 688 689 /* 690 * GObject's g_signal_connect_object has a documented bug. This function is 691 * identical except it does not leak the signal handler. 692 */ 693 gulong owl_signal_connect_object(gpointer sender, const gchar *detailed_signal, GCallback c_handler, gpointer receiver, GConnectFlags connect_flags) 694 { 695 g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (sender), 0); 696 g_return_val_if_fail (detailed_signal != NULL, 0); 697 g_return_val_if_fail (c_handler != NULL, 0); 698 699 if (receiver) { 700 SignalData *sdata; 701 GClosure *closure; 702 gulong signal_id; 703 704 g_return_val_if_fail (G_IS_OBJECT (receiver), 0); 705 706 closure = ((connect_flags & G_CONNECT_SWAPPED) ? g_cclosure_new_object_swap : g_cclosure_new_object) (c_handler, receiver); 707 signal_id = g_signal_connect_closure (sender, detailed_signal, closure, connect_flags & G_CONNECT_AFTER); 708 709 /* Register the missing hooks */ 710 sdata = g_slice_new0(SignalData); 711 sdata->sender = sender; 712 sdata->signal_id = signal_id; 713 714 g_closure_add_invalidate_notifier(closure, sdata, _closure_invalidated); 715 716 return signal_id; 717 } else { 718 return g_signal_connect_data(sender, detailed_signal, c_handler, NULL, NULL, connect_flags); 719 } 720 } 721 722 /* 723 * There are three ways the signal could come to an end: 724 * 725 * 1. The user explicitly disconnects it with the returned signal_id. 726 * - In that case, the disconnection unref's the closure, causing it 727 * to first be invalidated. The handler's already disconnected, so 728 * we have no work to do. 729 * 2. The sender gets destroyed. 730 * - GObject will disconnect each signal which then goes into the above 731 * case. Our handler does no work. 732 * 3. The receiver gets destroyed. 733 * - The GClosure was created by g_cclosure_new_object_{,swap} which gets 734 * invalidated when the receiver is destroyed. We then follow through case 1 735 * again, but *this* time, the handler has not been disconnected. We then 736 * clean up ourselves. 737 * 738 * We can't actually hook into this process earlier with weakrefs as GObject 739 * will, on object dispose, first disconnect signals, then invalidate closures, 740 * and notify weakrefs last. 741 */ 742 static void _closure_invalidated(gpointer data, GClosure *closure) 743 { 744 SignalData *sdata = data; 745 if (g_signal_handler_is_connected(sdata->sender, sdata->signal_id)) { 746 g_signal_handler_disconnect(sdata->sender, sdata->signal_id); 747 } 748 g_slice_free(SignalData, sdata); 749 } 750
Note: See TracChangeset
for help on using the changeset viewer.