Source: screen-message Version: 0.14-1 Severity: wishlist The attached patch adds better handling for hiding the edit widget on timeouts:
* a command-line option to give a custom timeout * doesn't render text underneath the edit widget * timeout doesn't occur when the user is moving the arrow keys around -- bye, pabs http://wiki.debian.org/PaulWise
--- screen-message-0.14.orig/sm.c +++ screen-message-0.14/sm.c @@ -33,8 +33,6 @@ #define min(x,y) ((x) < (y) ? (x) : (y)) -#define AUTOHIDE_TIMEOUT 5 - static gboolean quality = TRUE; static gboolean need_resize = TRUE; @@ -53,21 +51,27 @@ static char *background = NULL; static char *fontdesc = NULL; static rotation = 0; // 0 = normal, 1 = left, 2 = inverted, 3 = right +static int timeout = 5; +static int entry_visible = 0; gboolean hide_entry(gpointer *user_data) { + entry_visible = 0; gtk_widget_hide(entry_widget); gtk_widget_grab_focus(tv); + gtk_widget_queue_draw(window); return FALSE; } static void show_entry() { + entry_visible = 1; if (timeout_id) { g_source_remove(timeout_id); timeout_id = 0; } gtk_widget_show(entry_widget); - timeout_id = g_timeout_add_seconds (AUTOHIDE_TIMEOUT, (GSourceFunc)hide_entry, NULL); + timeout_id = g_timeout_add_seconds (timeout, (GSourceFunc)hide_entry, NULL); + gtk_widget_queue_draw(window); } static void realize(GtkWindow *window, GdkScreen *screen, gpointer data) { @@ -77,7 +81,7 @@ static void clear_text(GtkAccelGroup *accel, GObject *window, guint keyval, GdkModifierType modifier) { if( gtk_text_buffer_get_char_count(tb) ) { gtk_text_buffer_set_text(tb,"",-1); - show_entry(); + hide_entry(NULL); } else { gtk_main_quit(); } @@ -114,6 +118,9 @@ int h2 = window->allocation.height; int rw1, rh1; + + double s; + if (rotation == 0 || rotation == 2) { rw1 = w1; rh1 = h1; @@ -122,8 +129,10 @@ rh1 = w1; } - double s = min ((double)w2/rw1, (double)h2/rh1); - + if( entry_visible ) + h2 -= entry_widget->allocation.height; + + s = min ((double)w2/rw1, (double)h2/rh1); PangoMatrix matrix = PANGO_MATRIX_INIT; // Move matrix to the screen center @@ -168,6 +177,14 @@ hq(FALSE, TRUE); } +static void mark_deleted(GtkTextBuffer* tb, GtkTextMark* m, gpointer d){ + show_entry(); +} + +static void mark_set(GtkTextBuffer* tb, GtkTextIter* l, GtkTextMark* m, gpointer d){ + show_entry(); +} + static struct option const long_options[] = { {"help", no_argument, NULL, 'h'}, @@ -176,11 +193,12 @@ {"background", required_argument, NULL, 'b'}, {"font", required_argument, NULL, 'n'}, {"rotate", required_argument, NULL, 'r'}, + {"timeout", required_argument, NULL, 't'}, {0,0,0,0} }; static void usage(char *cmd) { - printf("Usage: %s [-h|--help] [-V|--version] [-f|--foreground=colordesc] [-b|--background=colordesc] [-n|--font=fontdesc] [-r|--rotate=0,1,2,3]\n", cmd); + printf("Usage: %s [-h|--help] [-V|--version] [-f|--foreground=colordesc] [-b|--background=colordesc] [-n|--font=fontdesc] [-r|--rotate=0,1,2,3] [-t|--timeout=5]\n", cmd); } static void version() { @@ -192,7 +210,7 @@ int c; int input_provided = 0; - while ((c = getopt_long (argc, argv, "hVf:b:n:r:", long_options, (int *) 0)) != EOF) { + while ((c = getopt_long (argc, argv, "hVf:b:n:r:t:", long_options, (int *) 0)) != EOF) { switch (c) { case 'h': usage(argv[0]); @@ -218,6 +236,9 @@ case 'r': rotation = atoi(optarg); break; + case 't': + timeout = atoi(optarg); + break; default: /* unknown switch received - at least * give usage but continue and use the @@ -353,6 +374,8 @@ g_signal_connect_after(G_OBJECT(window), "expose-event", G_CALLBACK(redraw), NULL); g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(newtext), NULL); g_signal_connect(G_OBJECT(tb), "changed", G_CALLBACK(newtext), NULL); + g_signal_connect(G_OBJECT(tb), "mark-set", G_CALLBACK(mark_set), NULL); + g_signal_connect(G_OBJECT(tb), "mark-deleted", G_CALLBACK(mark_deleted), NULL); if (!input_provided) show_entry();
signature.asc
Description: This is a digitally signed message part