Example #1
0
gint Selection::TimeOutCallback(gpointer data)
{
  Selection *oSelection = (Selection *)data;
  if (oSelection->Enable()) {

		if (conf->get_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key")) {
      bool do_scan = gpAppFrame->unlock_keys->is_pressed();
      if (!do_scan)
				return true;
    }

    if (oSelection->IsBusy) {
      oSelection->IsBusy++;
      if (oSelection->IsBusy*SELECTION_INTERVAL > 8000 ) {
				//"selection_received" signal is not received for 8 seconds.
				//there encounter some error,and i find that this often take a long time (serveral minutes) to get the signal at last,
				//during this perioed,if you call gtk_selection_convert(),the "selection_received" signal will not be received also,
				//and at last these signals are received at almost the same time...BAD.
				
				//so here create a new selection_widget, then call gtk_selection_convert()...this should can throw that error selection.
				//!!!:
				//But this seems(i am not sure) will make the widgets in StarDict become unselectable! see BUGS.
				g_warning("Error, selection data didn't received, retring!\n");
				oSelection->create_selection_widget();
				oSelection->IsBusy = 0;
      }
    } else {
      oSelection->IsBusy = 1;
      gtk_selection_convert (oSelection->selection_widget, GDK_SELECTION_PRIMARY, oSelection->UTF8_STRING_Atom, GDK_CURRENT_TIME);
    }
  }

  return true;
}