static void raw_print_done (GtkPrintJob * job, gint * ret, GError * err) { if (err) { g_printerr (_("Printing failed: %s\n"), err->message); *ret = 1; } yad_exit (options.data.def_resp); }
static gboolean combo_activate_cb (GtkWidget * w, GdkEventKey * ev, gpointer data) { #if GTK_CHECK_VERSION(2,24,0) if (ev->keyval == GDK_KEY_Return || ev->keyval == GDK_KEY_KP_Enter) #else if (ev->keyval == GDK_Return || ev->keyval == GDK_KP_Enter) #endif { if (options.plug == -1) yad_exit (YAD_RESPONSE_OK); return TRUE; } return FALSE; }
static gboolean handle_stdin (GIOChannel * channel, GIOCondition condition, gpointer data) { static guint pulsate_timeout = 0; float percentage = 0.0; if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { GString *string; GError *err = NULL; string = g_string_new (NULL); if (options.progress_data.pulsate) { if (pulsate_timeout == 0) pulsate_timeout = g_timeout_add (100, pulsate_progress_bar, NULL); } while (channel->is_readable != TRUE); do { gint status; do { status = g_io_channel_read_line_string (channel, string, NULL, &err); while (gtk_events_pending ()) gtk_main_iteration (); } while (status == G_IO_STATUS_AGAIN); if (status != G_IO_STATUS_NORMAL) { if (err) { g_printerr ("yad_progress_handle_stdin(): %s\n", err->message); g_error_free (err); err = NULL; } /* stop handling */ g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } if (string->str[0] == '#') { gchar *match; /* We have a comment, so let's try to change the label or write it to the log */ match = g_strcompress (g_strstrip (string->str + 1)); if (options.progress_data.log) { gchar *logline; GtkTextIter end; logline = g_strdup_printf ("%s\n", match); /* add new line */ gtk_text_buffer_get_end_iter (log_buffer, &end); gtk_text_buffer_insert (log_buffer, &end, logline, -1); g_free (logline); /* scroll to end */ while (gtk_events_pending ()) gtk_main_iteration (); gtk_text_buffer_get_end_iter (log_buffer, &end); gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (progress_log), &end, 0, FALSE, 0, 0); } else gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress_bar), match); g_free (match); } else { if (g_ascii_isdigit (*(string->str))) { /* Now try to convert the thing to a number */ percentage = atoi (string->str); if (percentage >= 100) { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); if (options.progress_data.autoclose && options.plug == -1) yad_exit (options.data.def_resp); } else gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); } } } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); g_string_free (string, TRUE); } if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); if (options.progress_data.pulsate) { g_source_remove (pulsate_timeout); pulsate_timeout = 0; } if (options.progress_data.autoclose && options.plug == -1) yad_exit (options.data.def_resp); g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } return TRUE; }
static void entry_activate_cb (GtkEntry * entry, gpointer data) { if (options.plug == -1) yad_exit (YAD_RESPONSE_OK); }